Assert.Contains Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Contains(String, String) |
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string. |
Contains(String, String, String) |
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string. |
Contains(String, String, StringComparison) |
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string. |
Contains(String, String, String, Object[]) |
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string. |
Contains(String, String, StringComparison, String) |
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string. |
Contains(String, String, StringComparison, String, Object[]) |
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string. |
Contains<T>(T, IEnumerable<T>, IEqualityComparer<T>, String) |
Tests whether the specified collection contains the given element. |
Contains<T>(Func<T,Boolean>, IEnumerable<T>, String, Object[]) |
Tests whether the specified collection contains the given element. |
Contains<T>(T, IEnumerable<T>, String, Object[]) |
Tests whether the specified collection contains the given element. |
Contains<T>(T, IEnumerable<T>, String) |
Tests whether the specified collection contains the given element. |
Contains<T>(T, IEnumerable<T>, IEqualityComparer<T>, String, Object[]) |
Tests whether the specified collection contains the given element. |
Contains<T>(IEnumerable<T>, Func<T,Boolean>, String) |
Tests whether the specified collection contains the given element. |
Contains<T>(Func<T,Boolean>, IEnumerable<T>) |
Tests whether the specified collection contains the given element. |
Contains<T>(T, IEnumerable<T>, IEqualityComparer<T>) |
Tests whether the specified collection contains the given element. |
Contains<T>(T, IEnumerable<T>) |
Tests whether the specified collection contains the given element. |
Contains(String, String)
- Source:
- Assert.Contains.cs
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string.
public static void Contains (string substring, string value);
static member Contains : string * string -> unit
Public Shared Sub Contains (substring As String, value As String)
Parameters
- substring
- String
The string expected to occur within value
.
- value
- String
The string that is expected to contain substring
.
Exceptions
value
is null, or substring
is null,
or value
does not contain substring
.
Applies to
Contains(String, String, String)
- Source:
- Assert.Contains.cs
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string.
public static void Contains (string substring, string value, string? message);
static member Contains : string * string * string -> unit
Public Shared Sub Contains (substring As String, value As String, message As String)
Parameters
- substring
- String
The string expected to occur within value
.
- value
- String
The string that is expected to contain substring
.
- message
- String
The message to include in the exception when substring
is not in value
. The message is shown in
test results.
Exceptions
value
is null, or substring
is null,
or value
does not contain substring
.
Applies to
Contains(String, String, StringComparison)
- Source:
- Assert.Contains.cs
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string.
public static void Contains (string substring, string value, StringComparison comparisonType);
static member Contains : string * string * StringComparison -> unit
Public Shared Sub Contains (substring As String, value As String, comparisonType As StringComparison)
Parameters
- substring
- String
The string expected to occur within value
.
- value
- String
The string that is expected to contain substring
.
- comparisonType
- StringComparison
The comparison method to compare strings comparisonType
.
Exceptions
value
is null, or substring
is null,
or value
does not contain substring
.
Applies to
Contains(String, String, String, Object[])
- Source:
- Assert.Contains.cs
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string.
public static void Contains (string substring, string value, string? message, params object?[]? parameters);
static member Contains : string * string * string * obj[] -> unit
Public Shared Sub Contains (substring As String, value As String, message As String, ParamArray parameters As Object())
Parameters
- substring
- String
The string expected to occur within value
.
- value
- String
The string that is expected to contain substring
.
- message
- String
The message to include in the exception when substring
is not in value
. The message is shown in
test results.
- parameters
- Object[]
An array of parameters to use when formatting message
.
Exceptions
value
is null, or substring
is null,
or value
does not contain substring
.
Applies to
Contains(String, String, StringComparison, String)
- Source:
- Assert.Contains.cs
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string.
public static void Contains (string substring, string value, StringComparison comparisonType, string? message);
static member Contains : string * string * StringComparison * string -> unit
Public Shared Sub Contains (substring As String, value As String, comparisonType As StringComparison, message As String)
Parameters
- substring
- String
The string expected to occur within value
.
- value
- String
The string that is expected to contain substring
.
- comparisonType
- StringComparison
The comparison method to compare strings comparisonType
.
- message
- String
The message to include in the exception when substring
is not in value
. The message is shown in
test results.
Exceptions
value
is null, or substring
is null,
or value
does not contain substring
.
Applies to
Contains(String, String, StringComparison, String, Object[])
- Source:
- Assert.Contains.cs
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string.
public static void Contains (string substring, string value, StringComparison comparisonType, string? message, params object?[]? parameters);
static member Contains : string * string * StringComparison * string * obj[] -> unit
Public Shared Sub Contains (substring As String, value As String, comparisonType As StringComparison, message As String, ParamArray parameters As Object())
Parameters
- substring
- String
The string expected to occur within value
.
- value
- String
The string that is expected to contain substring
.
- comparisonType
- StringComparison
The comparison method to compare strings comparisonType
.
- message
- String
The message to include in the exception when substring
is not in value
. The message is shown in
test results.
- parameters
- Object[]
An array of parameters to use when formatting message
.
Exceptions
value
is null, or substring
is null,
or value
does not contain substring
.
Applies to
Contains<T>(T, IEnumerable<T>, IEqualityComparer<T>, String)
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains the given element.
public static void Contains<T> (T expected, System.Collections.Generic.IEnumerable<T> collection, System.Collections.Generic.IEqualityComparer<T> comparer, string? message);
static member Contains : 'T * seq<'T> * System.Collections.Generic.IEqualityComparer<'T> * string -> unit
Public Shared Sub Contains(Of T) (expected As T, collection As IEnumerable(Of T), comparer As IEqualityComparer(Of T), message As String)
Type Parameters
- T
The type of the collection items.
Parameters
- expected
- T
The expected item.
- collection
- IEnumerable<T>
The collection.
- comparer
- IEqualityComparer<T>
An equality comparer to compare values.
- message
- String
The message to display when the assertion fails.
Applies to
Contains<T>(Func<T,Boolean>, IEnumerable<T>, String, Object[])
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains the given element.
public static void Contains<T> (Func<T,bool> predicate, System.Collections.Generic.IEnumerable<T> collection, string? message, params object?[]? parameters);
static member Contains : Func<'T, bool> * seq<'T> * string * obj[] -> unit
Public Shared Sub Contains(Of T) (predicate As Func(Of T, Boolean), collection As IEnumerable(Of T), message As String, ParamArray parameters As Object())
Type Parameters
- T
The type of the collection items.
Parameters
- collection
- IEnumerable<T>
The collection.
- message
- String
The message format to display when the assertion fails.
- parameters
- Object[]
The parameters to format the message.
Applies to
Contains<T>(T, IEnumerable<T>, String, Object[])
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains the given element.
public static void Contains<T> (T expected, System.Collections.Generic.IEnumerable<T> collection, string? message, params object?[]? parameters);
static member Contains : 'T * seq<'T> * string * obj[] -> unit
Public Shared Sub Contains(Of T) (expected As T, collection As IEnumerable(Of T), message As String, ParamArray parameters As Object())
Type Parameters
- T
The type of the collection items.
Parameters
- expected
- T
The expected item.
- collection
- IEnumerable<T>
The collection.
- message
- String
The message format to display when the assertion fails.
- parameters
- Object[]
The parameters to format the message.
Applies to
Contains<T>(T, IEnumerable<T>, String)
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains the given element.
public static void Contains<T> (T expected, System.Collections.Generic.IEnumerable<T> collection, string? message);
static member Contains : 'T * seq<'T> * string -> unit
Public Shared Sub Contains(Of T) (expected As T, collection As IEnumerable(Of T), message As String)
Type Parameters
- T
The type of the collection items.
Parameters
- expected
- T
The expected item.
- collection
- IEnumerable<T>
The collection.
- message
- String
The message to display when the assertion fails.
Applies to
Contains<T>(T, IEnumerable<T>, IEqualityComparer<T>, String, Object[])
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains the given element.
public static void Contains<T> (T expected, System.Collections.Generic.IEnumerable<T> collection, System.Collections.Generic.IEqualityComparer<T> comparer, string? message, params object?[]? parameters);
static member Contains : 'T * seq<'T> * System.Collections.Generic.IEqualityComparer<'T> * string * obj[] -> unit
Public Shared Sub Contains(Of T) (expected As T, collection As IEnumerable(Of T), comparer As IEqualityComparer(Of T), message As String, ParamArray parameters As Object())
Type Parameters
- T
The type of the collection items.
Parameters
- expected
- T
The expected item.
- collection
- IEnumerable<T>
The collection.
- comparer
- IEqualityComparer<T>
An equality comparer to compare values.
- message
- String
The message to display when the assertion fails.
- parameters
- Object[]
The parameters to format the message.
Applies to
Contains<T>(IEnumerable<T>, Func<T,Boolean>, String)
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains the given element.
public static void Contains<T> (System.Collections.Generic.IEnumerable<T> collection, Func<T,bool> predicate, string? message);
static member Contains : seq<'T> * Func<'T, bool> * string -> unit
Public Shared Sub Contains(Of T) (collection As IEnumerable(Of T), predicate As Func(Of T, Boolean), message As String)
Type Parameters
- T
The type of the collection items.
Parameters
- collection
- IEnumerable<T>
The collection.
- message
- String
The message to display when the assertion fails.
Applies to
Contains<T>(Func<T,Boolean>, IEnumerable<T>)
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains the given element.
public static void Contains<T> (Func<T,bool> predicate, System.Collections.Generic.IEnumerable<T> collection);
static member Contains : Func<'T, bool> * seq<'T> -> unit
Public Shared Sub Contains(Of T) (predicate As Func(Of T, Boolean), collection As IEnumerable(Of T))
Type Parameters
- T
The type of the collection items.
Parameters
- collection
- IEnumerable<T>
The collection.
Applies to
Contains<T>(T, IEnumerable<T>, IEqualityComparer<T>)
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains the given element.
public static void Contains<T> (T expected, System.Collections.Generic.IEnumerable<T> collection, System.Collections.Generic.IEqualityComparer<T> comparer);
static member Contains : 'T * seq<'T> * System.Collections.Generic.IEqualityComparer<'T> -> unit
Public Shared Sub Contains(Of T) (expected As T, collection As IEnumerable(Of T), comparer As IEqualityComparer(Of T))
Type Parameters
- T
The type of the collection items.
Parameters
- expected
- T
The expected item.
- collection
- IEnumerable<T>
The collection.
- comparer
- IEqualityComparer<T>
An equality comparer to compare values.
Applies to
Contains<T>(T, IEnumerable<T>)
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains the given element.
public static void Contains<T> (T expected, System.Collections.Generic.IEnumerable<T> collection);
static member Contains : 'T * seq<'T> -> unit
Public Shared Sub Contains(Of T) (expected As T, collection As IEnumerable(Of T))
Type Parameters
- T
The type of the collection items.
Parameters
- expected
- T
The expected item.
- collection
- IEnumerable<T>
The collection.