Assert.AreAllOfType Method

Definition

Overloads

Name Description
AreAllOfType(Type, IEnumerable, String, String, String)

Tests whether all elements in the specified collection are instances of (or derived from) the expected type and throws an exception if the expected type is not in the inheritance hierarchy of one or more of the elements, or if any element is null.

AreAllOfType<TExpected>(IEnumerable, String, String)

Tests whether all elements in the specified collection are instances of (or derived from) the expected type and throws an exception if the expected type is not in the inheritance hierarchy of one or more of the elements, or if any element is null.

AreAllOfType(Type, IEnumerable, String, String, String)

Source:
Assert.AreAllOfType.cs

Tests whether all elements in the specified collection are instances of (or derived from) the expected type and throws an exception if the expected type is not in the inheritance hierarchy of one or more of the elements, or if any element is null.

public static void AreAllOfType(Type? expectedType, System.Collections.IEnumerable? collection, string? message = "", string expectedTypeExpression = "", string collectionExpression = "");
static member AreAllOfType : Type * System.Collections.IEnumerable * string * string * string -> unit
Public Shared Sub AreAllOfType (expectedType As Type, collection As IEnumerable, Optional message As String = "", Optional expectedTypeExpression As String = "", Optional collectionExpression As String = "")

Parameters

expectedType
Type

The expected type of each element of collection.

collection
IEnumerable

The collection containing elements the test expects to be of the specified type.

message
String

The message to include in the exception when an element in collection is null or not an instance of expectedType. The message is shown in test results.

expectedTypeExpression
String

The syntactic expression of expectedType as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.

collectionExpression
String

The syntactic expression of collection as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.

Exceptions

Thrown if expectedType or collection is null, or some elements of collection are null or do not inherit from / implement expectedType.

Applies to

AreAllOfType<TExpected>(IEnumerable, String, String)

Source:
Assert.AreAllOfType.cs

Tests whether all elements in the specified collection are instances of (or derived from) the expected type and throws an exception if the expected type is not in the inheritance hierarchy of one or more of the elements, or if any element is null.

public static void AreAllOfType<TExpected>(System.Collections.IEnumerable? collection, string? message = "", string collectionExpression = "");
static member AreAllOfType : System.Collections.IEnumerable * string * string -> unit
Public Shared Sub AreAllOfType(Of TExpected) (collection As IEnumerable, Optional message As String = "", Optional collectionExpression As String = "")

Type Parameters

TExpected

The type each element of collection is expected to be.

Parameters

collection
IEnumerable

The collection containing elements the test expects to be of the specified type.

message
String

The message to include in the exception when an element in collection is null or not an instance of TExpected. The message is shown in test results.

collectionExpression
String

The syntactic expression of collection as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.

Exceptions

Thrown if collection is null or some elements of collection are null or do not inherit from / implement TExpected.

Applies to