CollectionAssert Class
Verifies true/false propositions associated with collections in unit tests.
Inheritance Hierarchy
System.Object
Microsoft.VisualStudio.TestTools.UnitTesting.CollectionAssert
Namespace: Microsoft.VisualStudio.TestTools.UnitTesting
Assembly: Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)
Syntax
'Declaration
Public NotInheritable Class CollectionAssert
public static class CollectionAssert
public ref class CollectionAssert abstract sealed
[<AbstractClass>]
[<Sealed>]
type CollectionAssert = class end
public final class CollectionAssert
Methods
Name | Description | |
---|---|---|
AllItemsAreInstancesOfType(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. | |
AllItemsAreInstancesOfType(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. | |
AllItemsAreInstancesOfType(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. | |
AllItemsAreNotNull(ICollection) | Verifies that all items in the specified collection are not nulla null reference (Nothing in Visual Basic). The assertion fails if any element is nulla null reference (Nothing in Visual Basic). | |
AllItemsAreNotNull(ICollection, String) | Verifies that all items in the specified collection are not nulla null reference (Nothing in Visual Basic). The assertion fails if any element is nulla null reference (Nothing in Visual Basic). Displays a message if the assertion fails. | |
AllItemsAreNotNull(ICollection, String, array<Object[]) | Verifies that all items in the specified collection are not nulla null reference (Nothing in Visual Basic). The assertion fails if any element is nulla null reference (Nothing in Visual Basic). Displays a message if the assertion fails, and applies the specified formatting to it. | |
AllItemsAreUnique(ICollection) | Verifies that all items in the specified collection are unique. The assertion fails if any two elements in the collection are equal. | |
AllItemsAreUnique(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. | |
AllItemsAreUnique(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. | |
AreEqual(ICollection, ICollection) | Verifies that two specified collections are equal. The assertion fails if the collections are not equal. | |
AreEqual(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. | |
AreEqual(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. | |
AreEqual(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. | |
AreEqual(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. | |
AreEqual(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. | |
AreEquivalent(ICollection, ICollection) | Verifies that two specified collections are equivalent. The assertion fails if the collections are not equivalent. | |
AreEquivalent(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. | |
AreEquivalent(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. | |
AreNotEqual(ICollection, ICollection) | Verifies that two specified collections are not equal. The assertion fails if the collections are equal. | |
AreNotEqual(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. | |
AreNotEqual(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. | |
AreNotEqual(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. | |
AreNotEqual(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. | |
AreNotEqual(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. | |
AreNotEquivalent(ICollection, ICollection) | Verifies that two specified collections are not equivalent. The assertion fails if the collections are equivalent. | |
AreNotEquivalent(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. | |
AreNotEquivalent(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. | |
Contains(ICollection, Object) | Verifies that the specified collection contains the specified element. The assertion fails if the element is not found in the collection. | |
Contains(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. | |
Contains(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. | |
DoesNotContain(ICollection, Object) | Verifies that the specified collection does not contain the specified element. The assertion fails if the element is found in the collection. | |
DoesNotContain(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. | |
DoesNotContain(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. | |
IsNotSubsetOf(ICollection, ICollection) | Verifies that the first collection is not a subset of the second collection. | |
IsNotSubsetOf(ICollection, ICollection, String) | Verifies that the first collection is not a subset of the second collection. Displays a message if the assertion fails. | |
IsNotSubsetOf(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. | |
IsSubsetOf(ICollection, ICollection) | Verifies that the first collection is a subset of the second collection. | |
IsSubsetOf(ICollection, ICollection, String) | Verifies that the first collection is a subset of the second collection. Displays a message if the assertion fails. | |
IsSubsetOf(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
Remarks
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
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.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Reference
Microsoft.VisualStudio.TestTools.UnitTesting Namespace