Share via


Assert.ContainsSingle Method

Definition

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

T

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

predicate
Func<T,Boolean>

A function to test each element for a condition.

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

T

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

predicate
Func<T,Boolean>

A function to test each element for a condition.

collection
IEnumerable<T>

The collection.

message
String

The message format to display when the assertion fails.

Returns

T

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

T

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

T

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

T

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

T

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

T

The item.

Applies to