CollectionAssert.AllItemsAreInstancesOfType Method (ICollection, Type, String, array<Object[])

Verifies that all elements in the specified collection are instances of the specified type. The assertion fails if there exists one element in the collection for which the specified type is not found in its inheritance hierarchy. Displays a message if the assertion fails, and applies the specified formatting to it.

Namespace:  Microsoft.VisualStudio.TestTools.UnitTesting
Assembly:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)

Syntax

'Declaration
Public Shared Sub AllItemsAreInstancesOfType ( _
    collection As ICollection, _
    expectedType As Type, _
    message As String, _
    ParamArray parameters As Object() _
)
'Usage
Dim collection As ICollection 
Dim expectedType As Type 
Dim message As String 
Dim parameters As Object()

CollectionAssert.AllItemsAreInstancesOfType(collection, _
    expectedType, message, parameters)
public static void AllItemsAreInstancesOfType(
    ICollection collection,
    Type expectedType,
    string message,
    params Object[] parameters
)
public:
static void AllItemsAreInstancesOfType(
    ICollection^ collection, 
    Type^ expectedType, 
    String^ message, 
    ... array<Object^>^ parameters
)
public static function AllItemsAreInstancesOfType(
    collection : ICollection, 
    expectedType : Type, 
    message : String, 
    ... parameters : Object[]
)

Parameters

  • expectedType
    Type: System.Type

    The type expected to be found in the inheritance hierarchy of every element in collection.

  • message
    Type: System.String

    A message to display if the assertion fails. This message can be seen in the unit test results.

  • parameters
    Type: array<System.Object[]

    An array of parameters to use when formatting message.

Exceptions

Exception Condition
AssertFailedException

An element in collection is nulla null reference (Nothing in Visual Basic) or expectedType is not found in the inheritance hierarchy of all elements in collection.

.NET Framework Security

See Also

Reference

CollectionAssert Class

CollectionAssert Members

AllItemsAreInstancesOfType Overload

Microsoft.VisualStudio.TestTools.UnitTesting Namespace

Other Resources

Using the Assert Classes