Click to Rate and Give Feedback
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
API Reference for Testing Tools for Visual Studio ALM
CollectionAssert Class

Verifies true/false propositions associated with collections in unit tests.

System..::.Object
  Microsoft.VisualStudio.TestTools.UnitTesting..::.CollectionAssert

Namespace:  Microsoft.VisualStudio.TestTools.UnitTesting
Assembly:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)
Visual Basic
Public NotInheritable Class CollectionAssert
C#
public static class CollectionAssert
Visual C++
public ref class CollectionAssert abstract sealed
F#
[<AbstractClass>]
[<Sealed>]
type CollectionAssert =  class end
JScript
public final class CollectionAssert
  NameDescription
Public methodStatic memberAllItemsAreInstancesOfType(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.
Public methodStatic memberAllItemsAreInstancesOfType(ICollection, Type, String)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.
Public methodStatic memberAllItemsAreInstancesOfType(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.
Public methodStatic memberAllItemsAreNotNull(ICollection)Verifies that all items in the specified collection are not nullNothingnullptra null reference (Nothing in Visual Basic). The assertion fails if any element is nullNothingnullptra null reference (Nothing in Visual Basic).
Public methodStatic memberAllItemsAreNotNull(ICollection, String)Verifies that all items in the specified collection are not nullNothingnullptra null reference (Nothing in Visual Basic). The assertion fails if any element is nullNothingnullptra null reference (Nothing in Visual Basic). Displays a message if the assertion fails.
Public methodStatic memberAllItemsAreNotNull(ICollection, String, array<Object>[]()[])Verifies that all items in the specified collection are not nullNothingnullptra null reference (Nothing in Visual Basic). The assertion fails if any element is nullNothingnullptra null reference (Nothing in Visual Basic). Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberAllItemsAreUnique(ICollection)Verifies that all items in the specified collection are unique. The assertion fails if any two elements in the collection are equal.
Public methodStatic memberAllItemsAreUnique(ICollection, String)Verifies that all items in the specified collection are unique. The assertion fails if any two elements in the collection are equal. Displays a message if the assertion fails.
Public methodStatic memberAllItemsAreUnique(ICollection, String, array<Object>[]()[])Verifies that all items in the specified collection are unique. The assertion fails if any two elements in the collection are equal. Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberAreEqual(ICollection, ICollection)Verifies that two specified collections are equal. The assertion fails if the collections are not equal.
Public methodStatic memberAreEqual(ICollection, ICollection, IComparer)Verifies that two specified collections are equal, using the specified method to compare the values of elements. The assertion fails if the collections are not equal.
Public methodStatic memberAreEqual(ICollection, ICollection, String)Verifies that two specified collections are equal. The assertion fails if the collections are not equal. Displays a message if the assertion fails.
Public methodStatic memberAreEqual(ICollection, ICollection, IComparer, String)Verifies that two specified collections are equal, using the specified method to compare the values of elements. The assertion fails if the collections are not equal. Displays a message if the assertion fails.
Public methodStatic memberAreEqual(ICollection, ICollection, String, array<Object>[]()[])Verifies that two specified collections are equal. The assertion fails if the collections are not equal. Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberAreEqual(ICollection, ICollection, IComparer, String, array<Object>[]()[])Verifies that two specified collections are equal, using the specified method to compare the values of elements. The assertion fails if the collections are not equal. Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberAreEquivalent(ICollection, ICollection)Verifies that two specified collections are equivalent. The assertion fails if the collections are not equivalent.
Public methodStatic memberAreEquivalent(ICollection, ICollection, String)Verifies that two specified collections are equivalent. The assertion fails if the collections are not equivalent. Displays a message if the assertion fails.
Public methodStatic memberAreEquivalent(ICollection, ICollection, String, array<Object>[]()[])Verifies that two specified collections are equivalent. The assertion fails if the collections are not equivalent. Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberAreNotEqual(ICollection, ICollection)Verifies that two specified collections are not equal. The assertion fails if the collections are equal.
Public methodStatic memberAreNotEqual(ICollection, ICollection, IComparer)Verifies that two specified collections are not equal, using the specified method to compare the values of elements. The assertion fails if the collections are equal.
Public methodStatic memberAreNotEqual(ICollection, ICollection, String)Verifies that two specified collections are not equal. The assertion fails if the collections are equal. Displays a message if the assertion fails.
Public methodStatic memberAreNotEqual(ICollection, ICollection, IComparer, String)Verifies that two specified collections are not equal, using the specified method to compare the values of elements. The assertion fails if the collections are equal. Displays a message if the assertion fails.
Public methodStatic memberAreNotEqual(ICollection, ICollection, String, array<Object>[]()[])Verifies that two specified collections are not equal. The assertion fails if the collections are equal. Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberAreNotEqual(ICollection, ICollection, IComparer, String, array<Object>[]()[])Verifies that two specified collections are not equal, using the specified method to compare the values of elements. The assertion fails if the collections are equal. Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberAreNotEquivalent(ICollection, ICollection)Verifies that two specified collections are not equivalent. The assertion fails if the collections are equivalent.
Public methodStatic memberAreNotEquivalent(ICollection, ICollection, String)Verifies that two specified collections are not equivalent. The assertion fails if the collections are equivalent. Displays a message if the assertion fails.
Public methodStatic memberAreNotEquivalent(ICollection, ICollection, String, array<Object>[]()[])Verifies that two specified collections are not equivalent. The assertion fails if the collections are equivalent. Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberContains(ICollection, Object)Verifies that the specified collection contains the specified element. The assertion fails if the element is not found in the collection.
Public methodStatic memberContains(ICollection, Object, String)Verifies that the specified collection contains the specified element. The assertion fails if the element is not found in the collection. Displays a message if the assertion fails.
Public methodStatic memberContains(ICollection, Object, String, array<Object>[]()[])Verifies that the specified collection contains the specified element. The assertion fails if the element is not found in the collection. Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberDoesNotContain(ICollection, Object)Verifies that the specified collection does not contain the specified element. The assertion fails if the element is found in the collection.
Public methodStatic memberDoesNotContain(ICollection, Object, String)Verifies that the specified collection does not contain the specified element. The assertion fails if the element is found in the collection. Displays a message if the assertion fails.
Public methodStatic memberDoesNotContain(ICollection, Object, String, array<Object>[]()[])Verifies that the specified collection does not contain the specified element. The assertion fails if the element is found in the collection. Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberIsNotSubsetOf(ICollection, ICollection)Verifies that the first collection is not a subset of the second collection.
Public methodStatic memberIsNotSubsetOf(ICollection, ICollection, String)Verifies that the first collection is not a subset of the second collection. Displays a message if the assertion fails.
Public methodStatic memberIsNotSubsetOf(ICollection, ICollection, String, array<Object>[]()[])Verifies that the first collection is not a subset of the second collection. Displays a message if the assertion fails, and applies the specified formatting to it.
Public methodStatic memberIsSubsetOf(ICollection, ICollection)Verifies that the first collection is a subset of the second collection.
Public methodStatic memberIsSubsetOf(ICollection, ICollection, String)Verifies that the first collection is a subset of the second collection. Displays a message if the assertion fails.
Public methodStatic memberIsSubsetOf(ICollection, ICollection, String, array<Object>[]()[])Verifies that the first collection is a subset of the second collection. Displays a message if the assertion fails, and applies the specified formatting to it.
Top

This class contains a set of static methods that evaluate a Boolean condition. If this condition evaluates to true, the assertion passes.

An assertion verifies an assumption of truth for compared conditions.

If the condition being verified is not true, the assertion fails.

Important noteImportant

The CollectionAssert class throws an AssertFailedException to signal a failure. This exception should not be captured. This exception is handled by the unit test engine to indicate an assert failure.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker