Assert.ContainsSingle Method

Definition

Overloads

ContainsSingle<T>(IEnumerable<T>)

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>, String)

Tests whether the specified collection contains exactly one element.

ContainsSingle<T>(IEnumerable<T>, String, Object[])

Tests whether the specified collection contains exactly one element.

ContainsSingle<T>(IEnumerable<T>)

Source:
Assert.Contains.cs

Tests whether the specified collection contains exactly one element.

C#
public static T ContainsSingle<T>(System.Collections.Generic.IEnumerable<T> collection);

Type Parameters

T

The type of the collection items.

Parameters

collection
IEnumerable<T>

The collection.

Returns

T

The item.

Applies to

MSTest.TestFramework 3.8.0
Proizvod Verzije
MSTest.TestFramework 3.8.0

ContainsSingle<T>(IEnumerable<T>, Assert.AssertSingleInterpolatedStringHandler<T>)

Source:
Assert.Contains.cs

Tests whether the specified collection contains exactly one element.

C#
public static T ContainsSingle<T>(System.Collections.Generic.IEnumerable<T> collection, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertSingleInterpolatedStringHandler<T> message);

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

MSTest.TestFramework 3.8.0
Proizvod Verzije
MSTest.TestFramework 3.8.0

ContainsSingle<T>(IEnumerable<T>, String)

Source:
Assert.Contains.cs

Tests whether the specified collection contains exactly one element.

C#
public static T ContainsSingle<T>(System.Collections.Generic.IEnumerable<T> collection, string? message);

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

MSTest.TestFramework 3.8.0
Proizvod Verzije
MSTest.TestFramework 3.8.0

ContainsSingle<T>(IEnumerable<T>, String, Object[])

Source:
Assert.Contains.cs

Tests whether the specified collection contains exactly one element.

C#
public static T ContainsSingle<T>(System.Collections.Generic.IEnumerable<T> collection, string? message, params object?[]? parameters);

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

MSTest.TestFramework 3.8.0
Proizvod Verzije
MSTest.TestFramework 3.8.0