Verifies that the specified sequence, collection, or array contains the expected number of elements.

Namespace:  MbUnit.Framework
Assembly:  MbUnit (in MbUnit.dll) Version: 3.3.0.0 (3.3.610.0)

Syntax

C#
public static void Count(
	int expectedCount,
	IEnumerable values
)
Visual Basic (Declaration)
Public Shared Sub Count ( _
	expectedCount As Integer, _
	values As IEnumerable _
)

Parameters

expectedCount
Type: System..::.Int32
The expected number of elements.
values
Type: System.Collections..::.IEnumerable
The enumeration of elements to count.

Remarks

The assertion counts the elements according to the underlying type of the sequence.

  • Uses Length if the sequence is an array.
  • Uses Count or Count if the sequence is a collection such as List<(Of <(T>)>) or Dictionary<(Of <(TKey, TValue>)>). It enumerates and counts the elements as well.
  • Enumerates and counts the elements if the sequence is a simple IEnumerable.

Exceptions

ExceptionCondition
Gallio.Framework.Assertions..::.AssertionExceptionThrown if the verification failed unless the current AssertionFailureBehavior indicates otherwise.
System..::.ArgumentOutOfRangeExceptionThrown if expectedCount is negative.
System..::.ArgumentNullExceptionThrown if values is null.

See Also