Skip to content

EnumerableAssertions<TSelf, TEnumerable, T>.ContainSingle Method ​

Overloads ​

NameDescription
ContainSingle()Asserts that the enumerable contains exactly one item.
ContainSingle(Func<T, Boolean>, String)Asserts that the enumerable contains exactly one item that satisfies the specified predicate.

ContainSingle() ​

Asserts that the enumerable contains exactly one item.

c#
public AssertionsChain<ObjectAssertions<T>, T> ContainSingle();

View source

Returns ​

AssertionsChain<ObjectAssertions<T>, T>

An AssertionsChain<TAssertions, T> for the single item.

ContainSingle(Func<T, Boolean>, String) ​

Asserts that the enumerable contains exactly one item that satisfies the specified predicate.

c#
public AssertionsChain<ObjectAssertions<T>, T> ContainSingle(Func<T, bool> predicate, string? predicateExpression = null);

View source

Parameters ​

NameTypeDescription
predicateFunc<T, Boolean>The predicate to match.
predicateExpressionStringThe expression text of the predicate, captured automatically.

Returns ​

AssertionsChain<ObjectAssertions<T>, T>

An AssertionsChain<TAssertions, T> for the single matching item.