CollectionAssert.AllItemsAreInstancesOfType Method (ICollection, Type)

Verifies that all elements in the specified collection are instances of the specified type. The assertion fails if for any element the type is not found in its inheritance hierarchy.

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


Public Shared Sub AllItemsAreInstancesOfType ( _
    collection As ICollection, _
    expectedType As Type _
public static void AllItemsAreInstancesOfType(
    ICollection collection,
    Type expectedType
static void AllItemsAreInstancesOfType(
    ICollection^ collection, 
    Type^ expectedType
static member AllItemsAreInstancesOfType : 
        collection:ICollection * 
        expectedType:Type -> unit 
public static function AllItemsAreInstancesOfType(
    collection : ICollection, 
    expectedType : Type


  • expectedType
    Type: System.Type
    The type expected to be found in the inheritance hierarchy of every element in collection.


Exception Condition

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


CollectionAssert Class

AllItemsAreInstancesOfType Overload

Microsoft.VisualStudio.TestTools.UnitTesting Namespace

Other Resources

Using the Assert Classes