Method Contains
- Namespace
- Xunit
- Assembly
- xunit.v3.assert.dll
Contains<T>(T, IEnumerable<T>)
Verifies that a collection contains a given object.
public static void Contains<T>(T expected, IEnumerable<T> collection)
Parameters
expectedTThe object expected to be in the collection
collectionIEnumerable<T>The collection to be inspected
Type Parameters
TThe type of the object to be verified
Exceptions
Thrown when the object is not present in the collection
Contains<T>(T, IEnumerable<T>, IEqualityComparer<T>)
Verifies that a collection contains a given object, using an equality comparer.
public static void Contains<T>(T expected, IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
expectedTThe object expected to be in the collection
collectionIEnumerable<T>The collection to be inspected
comparerIEqualityComparer<T>The comparer used to equate objects in the collection with the expected object
Type Parameters
TThe type of the object to be verified
Exceptions
Thrown when the object is not present in the collection
Contains<T>(IEnumerable<T>, Predicate<T>)
Verifies that a collection contains a given object.
public static void Contains<T>(IEnumerable<T> collection, Predicate<T> filter)
Parameters
collectionIEnumerable<T>The collection to be inspected
filterPredicate<T>The filter used to find the item you're ensuring the collection contains
Type Parameters
TThe type of the object to be verified
Exceptions
Thrown when the object is not present in the collection
Contains<TKey, TValue>(TKey, IDictionary<TKey, TValue>)
Verifies that a dictionary contains a given key.
public static TValue Contains<TKey, TValue>(TKey expected, IDictionary<TKey, TValue> collection) where TKey : notnull
Parameters
expectedTKeyThe object expected to be in the collection.
collectionIDictionary<TKey, TValue>The collection to be inspected.
Returns
- TValue
The value associated with
expected.
Type Parameters
TKeyThe type of the keys of the object to be verified.
TValueThe type of the values of the object to be verified.
Exceptions
Thrown when the object is not present in the collection
Contains<TKey, TValue>(TKey, IReadOnlyDictionary<TKey, TValue>)
Verifies that a read-only dictionary contains a given key.
public static TValue Contains<TKey, TValue>(TKey expected, IReadOnlyDictionary<TKey, TValue> collection) where TKey : notnull
Parameters
expectedTKeyThe object expected to be in the collection.
collectionIReadOnlyDictionary<TKey, TValue>The collection to be inspected.
Returns
- TValue
The value associated with
expected.
Type Parameters
TKeyThe type of the keys of the object to be verified.
TValueThe type of the values of the object to be verified.
Exceptions
Thrown when the object is not present in the collection
Contains<TKey, TValue>(TKey, ConcurrentDictionary<TKey, TValue>)
Verifies that a dictionary contains a given key.
public static TValue Contains<TKey, TValue>(TKey expected, ConcurrentDictionary<TKey, TValue> collection) where TKey : notnull
Parameters
expectedTKeyThe object expected to be in the collection.
collectionConcurrentDictionary<TKey, TValue>The collection to be inspected.
Returns
- TValue
The value associated with
expected.
Type Parameters
TKeyThe type of the keys of the object to be verified.
TValueThe type of the values of the object to be verified.
Exceptions
Thrown when the object is not present in the collection
Contains<TKey, TValue>(TKey, Dictionary<TKey, TValue>)
Verifies that a dictionary contains a given key.
public static TValue Contains<TKey, TValue>(TKey expected, Dictionary<TKey, TValue> collection) where TKey : notnull
Parameters
expectedTKeyThe object expected to be in the collection.
collectionDictionary<TKey, TValue>The collection to be inspected.
Returns
- TValue
The value associated with
expected.
Type Parameters
TKeyThe type of the keys of the object to be verified.
TValueThe type of the values of the object to be verified.
Exceptions
Thrown when the object is not present in the collection
Contains<TKey, TValue>(TKey, ReadOnlyDictionary<TKey, TValue>)
Verifies that a dictionary contains a given key.
public static TValue Contains<TKey, TValue>(TKey expected, ReadOnlyDictionary<TKey, TValue> collection) where TKey : notnull
Parameters
expectedTKeyThe object expected to be in the collection.
collectionReadOnlyDictionary<TKey, TValue>The collection to be inspected.
Returns
- TValue
The value associated with
expected.
Type Parameters
TKeyThe type of the keys of the object to be verified.
TValueThe type of the values of the object to be verified.
Exceptions
Thrown when the object is not present in the collection
Contains<TKey, TValue>(TKey, ImmutableDictionary<TKey, TValue>)
Verifies that a dictionary contains a given key.
public static TValue Contains<TKey, TValue>(TKey expected, ImmutableDictionary<TKey, TValue> collection) where TKey : notnull
Parameters
expectedTKeyThe object expected to be in the collection.
collectionImmutableDictionary<TKey, TValue>The collection to be inspected.
Returns
- TValue
The value associated with
expected.
Type Parameters
TKeyThe type of the keys of the object to be verified.
TValueThe type of the values of the object to be verified.
Exceptions
Thrown when the object is not present in the collection
Contains<T>(Memory<T>, Memory<T>)
Verifies that a Memory contains a given sub-Memory
public static void Contains<T>(Memory<T> expectedSubMemory, Memory<T> actualMemory) where T : IEquatable<T>
Parameters
expectedSubMemoryMemory<T>The sub-Memory expected to be in the Memory
actualMemoryMemory<T>The Memory to be inspected
Type Parameters
T
Exceptions
Thrown when the sub-Memory is not present inside the Memory
Contains<T>(Memory<T>, ReadOnlyMemory<T>)
Verifies that a Memory contains a given sub-Memory
public static void Contains<T>(Memory<T> expectedSubMemory, ReadOnlyMemory<T> actualMemory) where T : IEquatable<T>
Parameters
expectedSubMemoryMemory<T>The sub-Memory expected to be in the Memory
actualMemoryReadOnlyMemory<T>The Memory to be inspected
Type Parameters
T
Exceptions
Thrown when the sub-Memory is not present inside the Memory
Contains<T>(ReadOnlyMemory<T>, Memory<T>)
Verifies that a Memory contains a given sub-Memory
public static void Contains<T>(ReadOnlyMemory<T> expectedSubMemory, Memory<T> actualMemory) where T : IEquatable<T>
Parameters
expectedSubMemoryReadOnlyMemory<T>The sub-Memory expected to be in the Memory
actualMemoryMemory<T>The Memory to be inspected
Type Parameters
T
Exceptions
Thrown when the sub-Memory is not present inside the Memory
Contains<T>(ReadOnlyMemory<T>, ReadOnlyMemory<T>)
Verifies that a Memory contains a given sub-Memory
public static void Contains<T>(ReadOnlyMemory<T> expectedSubMemory, ReadOnlyMemory<T> actualMemory) where T : IEquatable<T>
Parameters
expectedSubMemoryReadOnlyMemory<T>The sub-Memory expected to be in the Memory
actualMemoryReadOnlyMemory<T>The Memory to be inspected
Type Parameters
T
Exceptions
Thrown when the sub-Memory is not present inside the Memory
Contains<T>(T, ISet<T>)
Verifies that the set contains the given object.
public static void Contains<T>(T expected, ISet<T> set)
Parameters
expectedTThe object expected to be in the set
setISet<T>The set to be inspected
Type Parameters
TThe type of the object to be verified
Exceptions
Thrown when the object is not present in the set
Contains<T>(T, HashSet<T>)
Verifies that the hashset contains the given object.
public static void Contains<T>(T expected, HashSet<T> set)
Parameters
expectedTThe object expected to be in the set
setHashSet<T>The set to be inspected
Type Parameters
TThe type of the object to be verified
Exceptions
Thrown when the object is not present in the set
Contains<T>(T, SortedSet<T>)
Verifies that the sorted hashset contains the given object.
public static void Contains<T>(T expected, SortedSet<T> set)
Parameters
expectedTThe object expected to be in the set
setSortedSet<T>The set to be inspected
Type Parameters
TThe type of the object to be verified
Exceptions
Thrown when the object is not present in the set
Contains<T>(T, ImmutableHashSet<T>)
Verifies that the immutable hashset contains the given object.
public static void Contains<T>(T expected, ImmutableHashSet<T> set)
Parameters
expectedTThe object expected to be in the set
setImmutableHashSet<T>The set to be inspected
Type Parameters
TThe type of the object to be verified
Exceptions
Thrown when the object is not present in the set
Contains<T>(T, ImmutableSortedSet<T>)
Verifies that the immutable sorted hashset contains the given object.
public static void Contains<T>(T expected, ImmutableSortedSet<T> set)
Parameters
expectedTThe object expected to be in the set
setImmutableSortedSet<T>The set to be inspected
Type Parameters
TThe type of the object to be verified
Exceptions
Thrown when the object is not present in the set
Contains<T>(Span<T>, Span<T>)
Verifies that a span contains a given sub-span
public static void Contains<T>(Span<T> expectedSubSpan, Span<T> actualSpan) where T : IEquatable<T>
Parameters
expectedSubSpanSpan<T>The sub-span expected to be in the span
actualSpanSpan<T>The span to be inspected
Type Parameters
T
Exceptions
Thrown when the sub-span is not present inside the span
Contains<T>(Span<T>, ReadOnlySpan<T>)
Verifies that a span contains a given sub-span
public static void Contains<T>(Span<T> expectedSubSpan, ReadOnlySpan<T> actualSpan) where T : IEquatable<T>
Parameters
expectedSubSpanSpan<T>The sub-span expected to be in the span
actualSpanReadOnlySpan<T>The span to be inspected
Type Parameters
T
Exceptions
Thrown when the sub-span is not present inside the span
Contains<T>(ReadOnlySpan<T>, Span<T>)
Verifies that a span contains a given sub-span
public static void Contains<T>(ReadOnlySpan<T> expectedSubSpan, Span<T> actualSpan) where T : IEquatable<T>
Parameters
expectedSubSpanReadOnlySpan<T>The sub-span expected to be in the span
actualSpanSpan<T>The span to be inspected
Type Parameters
T
Exceptions
Thrown when the sub-span is not present inside the span
Contains<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
Verifies that a span contains a given sub-span
public static void Contains<T>(ReadOnlySpan<T> expectedSubSpan, ReadOnlySpan<T> actualSpan) where T : IEquatable<T>
Parameters
expectedSubSpanReadOnlySpan<T>The sub-span expected to be in the span
actualSpanReadOnlySpan<T>The span to be inspected
Type Parameters
T
Exceptions
Thrown when the sub-span is not present inside the span
Contains(string, string?)
Verifies that a string contains a given sub-string, using the current culture.
public static void Contains(string expectedSubstring, string? actualString)
Parameters
expectedSubstringstringThe sub-string expected to be in the string
actualStringstringThe string to be inspected
Exceptions
Thrown when the sub-string is not present inside the string
Contains(string, string?, StringComparison)
Verifies that a string contains a given sub-string, using the given comparison type.
public static void Contains(string expectedSubstring, string? actualString, StringComparison comparisonType)
Parameters
expectedSubstringstringThe sub-string expected to be in the string
actualStringstringThe string to be inspected
comparisonTypeStringComparisonThe type of string comparison to perform
Exceptions
Thrown when the sub-string is not present inside the string
Contains(Memory<char>, Memory<char>)
Verifies that a string contains a given sub-string, using the current culture.
public static void Contains(Memory<char> expectedSubstring, Memory<char> actualString)
Parameters
expectedSubstringMemory<char>The sub-string expected to be in the string
actualStringMemory<char>The string to be inspected
Exceptions
Thrown when the sub-string is not present inside the string
Contains(Memory<char>, ReadOnlyMemory<char>)
Verifies that a string contains a given sub-string, using the current culture.
public static void Contains(Memory<char> expectedSubstring, ReadOnlyMemory<char> actualString)
Parameters
expectedSubstringMemory<char>The sub-string expected to be in the string
actualStringReadOnlyMemory<char>The string to be inspected
Exceptions
Thrown when the sub-string is not present inside the string
Contains(ReadOnlyMemory<char>, Memory<char>)
Verifies that a string contains a given sub-string, using the current culture.
public static void Contains(ReadOnlyMemory<char> expectedSubstring, Memory<char> actualString)
Parameters
expectedSubstringReadOnlyMemory<char>The sub-string expected to be in the string
actualStringMemory<char>The string to be inspected
Exceptions
Thrown when the sub-string is not present inside the string
Contains(ReadOnlyMemory<char>, ReadOnlyMemory<char>)
Verifies that a string contains a given sub-string, using the current culture.
public static void Contains(ReadOnlyMemory<char> expectedSubstring, ReadOnlyMemory<char> actualString)
Parameters
expectedSubstringReadOnlyMemory<char>The sub-string expected to be in the string
actualStringReadOnlyMemory<char>The string to be inspected
Exceptions
Thrown when the sub-string is not present inside the string
Contains(Memory<char>, Memory<char>, StringComparison)
Verifies that a string contains a given sub-string, using the given comparison type.
public static void Contains(Memory<char> expectedSubstring, Memory<char> actualString, StringComparison comparisonType = StringComparison.CurrentCulture)
Parameters
expectedSubstringMemory<char>The sub-string expected to be in the string
actualStringMemory<char>The string to be inspected
comparisonTypeStringComparisonThe type of string comparison to perform
Exceptions
Thrown when the sub-string is not present inside the string
Contains(Memory<char>, ReadOnlyMemory<char>, StringComparison)
Verifies that a string contains a given sub-string, using the given comparison type.
public static void Contains(Memory<char> expectedSubstring, ReadOnlyMemory<char> actualString, StringComparison comparisonType = StringComparison.CurrentCulture)
Parameters
expectedSubstringMemory<char>The sub-string expected to be in the string
actualStringReadOnlyMemory<char>The string to be inspected
comparisonTypeStringComparisonThe type of string comparison to perform
Exceptions
Thrown when the sub-string is not present inside the string
Contains(ReadOnlyMemory<char>, Memory<char>, StringComparison)
Verifies that a string contains a given sub-string, using the given comparison type.
public static void Contains(ReadOnlyMemory<char> expectedSubstring, Memory<char> actualString, StringComparison comparisonType = StringComparison.CurrentCulture)
Parameters
expectedSubstringReadOnlyMemory<char>The sub-string expected to be in the string
actualStringMemory<char>The string to be inspected
comparisonTypeStringComparisonThe type of string comparison to perform
Exceptions
Thrown when the sub-string is not present inside the string
Contains(ReadOnlyMemory<char>, ReadOnlyMemory<char>, StringComparison)
Verifies that a string contains a given sub-string, using the given comparison type.
public static void Contains(ReadOnlyMemory<char> expectedSubstring, ReadOnlyMemory<char> actualString, StringComparison comparisonType = StringComparison.CurrentCulture)
Parameters
expectedSubstringReadOnlyMemory<char>The sub-string expected to be in the string
actualStringReadOnlyMemory<char>The string to be inspected
comparisonTypeStringComparisonThe type of string comparison to perform
Exceptions
Thrown when the sub-string is not present inside the string
Contains(Span<char>, Span<char>, StringComparison)
Verifies that a string contains a given string, using the given comparison type.
public static void Contains(Span<char> expectedSubstring, Span<char> actualString, StringComparison comparisonType = StringComparison.CurrentCulture)
Parameters
expectedSubstringSpan<char>The string expected to be in the string
actualStringSpan<char>The string to be inspected
comparisonTypeStringComparisonThe type of string comparison to perform
Exceptions
Thrown when the string is not present inside the string
Contains(Span<char>, ReadOnlySpan<char>, StringComparison)
Verifies that a string contains a given string, using the given comparison type.
public static void Contains(Span<char> expectedSubstring, ReadOnlySpan<char> actualString, StringComparison comparisonType = StringComparison.CurrentCulture)
Parameters
expectedSubstringSpan<char>The string expected to be in the string
actualStringReadOnlySpan<char>The string to be inspected
comparisonTypeStringComparisonThe type of string comparison to perform
Exceptions
Thrown when the string is not present inside the string
Contains(ReadOnlySpan<char>, Span<char>, StringComparison)
Verifies that a string contains a given string, using the given comparison type.
public static void Contains(ReadOnlySpan<char> expectedSubstring, Span<char> actualString, StringComparison comparisonType = StringComparison.CurrentCulture)
Parameters
expectedSubstringReadOnlySpan<char>The string expected to be in the string
actualStringSpan<char>The string to be inspected
comparisonTypeStringComparisonThe type of string comparison to perform
Exceptions
Thrown when the string is not present inside the string
Contains(ReadOnlySpan<char>, ReadOnlySpan<char>, StringComparison)
Verifies that a string contains a given string, using the given comparison type.
public static void Contains(ReadOnlySpan<char> expectedSubstring, ReadOnlySpan<char> actualString, StringComparison comparisonType = StringComparison.CurrentCulture)
Parameters
expectedSubstringReadOnlySpan<char>The string expected to be in the string
actualStringReadOnlySpan<char>The string to be inspected
comparisonTypeStringComparisonThe type of string comparison to perform
Exceptions
Thrown when the string is not present inside the string
Contains(Span<char>, Span<char>)
Verifies that a string contains a given string, using the current culture.
public static void Contains(Span<char> expectedSubstring, Span<char> actualString)
Parameters
expectedSubstringSpan<char>The string expected to be in the string
actualStringSpan<char>The string to be inspected
Exceptions
Thrown when the string is not present inside the string
Contains(Span<char>, ReadOnlySpan<char>)
Verifies that a string contains a given string, using the current culture.
public static void Contains(Span<char> expectedSubstring, ReadOnlySpan<char> actualString)
Parameters
expectedSubstringSpan<char>The string expected to be in the string
actualStringReadOnlySpan<char>The string to be inspected
Exceptions
Thrown when the string is not present inside the string
Contains(ReadOnlySpan<char>, Span<char>)
Verifies that a string contains a given string, using the current culture.
public static void Contains(ReadOnlySpan<char> expectedSubstring, Span<char> actualString)
Parameters
expectedSubstringReadOnlySpan<char>The string expected to be in the string
actualStringSpan<char>The string to be inspected
Exceptions
Thrown when the string is not present inside the string
Contains(ReadOnlySpan<char>, ReadOnlySpan<char>)
Verifies that a string contains a given string, using the current culture.
public static void Contains(ReadOnlySpan<char> expectedSubstring, ReadOnlySpan<char> actualString)
Parameters
expectedSubstringReadOnlySpan<char>The string expected to be in the string
actualStringReadOnlySpan<char>The string to be inspected
Exceptions
Thrown when the string is not present inside the string