Assert.ContainsSingle 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
| ContainsSingle<T>(IEnumerable<T>, String, String) |
Tests whether the specified collection contains exactly one element. |
| ContainsSingle<T>(Func<T,Boolean>, IEnumerable<T>, String, String, String) |
Tests whether the specified collection contains exactly one element that matches the given predicate. |
| ContainsSingle<T>(Func<T,Boolean>, IEnumerable<T>, String) |
Tests whether the specified collection contains exactly one element that matches the given predicate. |
| ContainsSingle<T>(IEnumerable<T>, String, Object[]) |
Tests whether the specified collection contains exactly one element. |
| ContainsSingle<T>(IEnumerable<T>, String) |
Tests whether the specified collection contains exactly one element. |
| ContainsSingle<T>(IEnumerable<T>, Assert.AssertSingleInterpolatedStringHandler<T>) |
Tests whether the specified collection contains exactly one element. |
| ContainsSingle<T>(IEnumerable<T>) |
Tests whether the specified collection contains exactly one element. |
| ContainsSingle<T>(IEnumerable<T>, Assert.AssertSingleInterpolatedStringHandler<T>, String) |
Tests whether the specified collection contains exactly one element. |
ContainsSingle<T>(IEnumerable<T>, String, String)
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains exactly one element.
public static T ContainsSingle<T>(System.Collections.Generic.IEnumerable<T> collection, string? message = "", string collectionExpression = "");
static member ContainsSingle : seq<'T> * string * string -> 'T
Public Shared Function ContainsSingle(Of T) (collection As IEnumerable(Of T), Optional message As String = "", Optional collectionExpression As String = "") As T
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.
- collectionExpression
- String
The syntactic expression of collection as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Returns
The item.
Applies to
ContainsSingle<T>(Func<T,Boolean>, IEnumerable<T>, String, String, String)
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains exactly one element that matches the given predicate.
public static T ContainsSingle<T>(Func<T,bool> predicate, System.Collections.Generic.IEnumerable<T> collection, string? message = "", string predicateExpression = "", string collectionExpression = "");
static member ContainsSingle : Func<'T, bool> * seq<'T> * string * string * string -> 'T
Public Shared Function ContainsSingle(Of T) (predicate As Func(Of T, Boolean), collection As IEnumerable(Of T), Optional message As String = "", Optional predicateExpression As String = "", Optional collectionExpression As String = "") As T
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.
- predicateExpression
- String
The syntactic expression of predicate as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
- collectionExpression
- String
The syntactic expression of collection as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Returns
The item that matches the predicate.
Applies to
ContainsSingle<T>(Func<T,Boolean>, IEnumerable<T>, String)
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains exactly one element that matches the given predicate.
public static T ContainsSingle<T>(Func<T,bool> predicate, System.Collections.Generic.IEnumerable<T> collection, string message = "");
static member ContainsSingle : Func<'T, bool> * seq<'T> * string -> 'T
Public Shared Function ContainsSingle(Of T) (predicate As Func(Of T, Boolean), collection As IEnumerable(Of T), Optional message As String = "") As T
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.
Returns
The item that matches the predicate.
Applies to
ContainsSingle<T>(IEnumerable<T>, String, Object[])
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains exactly one element.
public static T ContainsSingle<T>(System.Collections.Generic.IEnumerable<T> collection, string? message, params object?[]? parameters);
static member ContainsSingle : seq<'T> * string * obj[] -> 'T
Public Shared Function ContainsSingle(Of T) (collection As IEnumerable(Of T), message As String, ParamArray parameters As Object()) As T
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.
Returns
The item.
Applies to
ContainsSingle<T>(IEnumerable<T>, String)
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains exactly one element.
public static T ContainsSingle<T>(System.Collections.Generic.IEnumerable<T> collection, string? message);
static member ContainsSingle : seq<'T> * string -> 'T
Public Shared Function ContainsSingle(Of T) (collection As IEnumerable(Of T), message As String) As T
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.
Returns
The item.
Applies to
ContainsSingle<T>(IEnumerable<T>, Assert.AssertSingleInterpolatedStringHandler<T>)
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains exactly one element.
public static T ContainsSingle<T>(System.Collections.Generic.IEnumerable<T> collection, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertSingleInterpolatedStringHandler<T> message);
static member ContainsSingle : seq<'T> * AssertSingleInterpolatedStringHandler -> 'T
Public Shared Function ContainsSingle(Of T) (collection As IEnumerable(Of T), ByRef message As Assert.AssertSingleInterpolatedStringHandler(Of T)) As T
Type Parameters
- T
The type of the collection items.
Parameters
- collection
- IEnumerable<T>
The collection.
- message
- Assert.AssertSingleInterpolatedStringHandler<T>
The message to display when the assertion fails.
Returns
The item.
Applies to
ContainsSingle<T>(IEnumerable<T>)
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains exactly one element.
public static T ContainsSingle<T>(System.Collections.Generic.IEnumerable<T> collection);
static member ContainsSingle : seq<'T> -> 'T
Public Shared Function ContainsSingle(Of T) (collection As IEnumerable(Of T)) As T
Type Parameters
- T
The type of the collection items.
Parameters
- collection
- IEnumerable<T>
The collection.
Returns
The item.
Applies to
ContainsSingle<T>(IEnumerable<T>, Assert.AssertSingleInterpolatedStringHandler<T>, String)
- Source:
- Assert.Contains.cs
Tests whether the specified collection contains exactly one element.
public static T ContainsSingle<T>(System.Collections.Generic.IEnumerable<T> collection, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertSingleInterpolatedStringHandler<T> message, string collectionExpression = "");
static member ContainsSingle : seq<'T> * AssertSingleInterpolatedStringHandler * string -> 'T
Public Shared Function ContainsSingle(Of T) (collection As IEnumerable(Of T), ByRef message As Assert.AssertSingleInterpolatedStringHandler(Of T), Optional collectionExpression As String = "") As T
Type Parameters
- T
The type of the collection items.
Parameters
- collection
- IEnumerable<T>
The collection.
- message
- Assert.AssertSingleInterpolatedStringHandler<T>
The message to display when the assertion fails.
- collectionExpression
- String
The syntactic expression of collection as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Returns
The item.