Skip to content

CountExtensions.HaveCount Method ​

Definition ​

Asserts that the enumerable has the specified number of elements.

c#
public static AssertionsChain<TAssertions, T> HaveCount<TAssertions, T>(this ObjectAssertions<TAssertions, T> assertions, int expectedCount)
   where TAssertions : ObjectAssertions<TAssertions, T>
   where T : IEnumerable;

View source

Type Parameters ​

NameDescription
TAssertionsThe type of the assertions object.
TThe type of the enumerable.

Parameters ​

NameTypeDescription
assertionsObjectAssertions<TAssertions, T>The assertions object.
expectedCountInt32The expected number of elements.

Returns ​

AssertionsChain<TAssertions, T>

An AssertionsChain<TAssertions, T> for chaining further assertions.