haveCount method

IterableAssertions<T> haveCount(
  1. int expected
)

Asserts that the number of items in the collection matches the supplied expected amount.

Implementation

IterableAssertions<T> haveCount(int expected) {
  if (isReversed) {
    if (subject!.length == expected) {
      throw ShouldlyTestFailureError(
        'Current length ${subject!.length} is not equal to $expected.',
      );
    }
  } else {
    if (subject!.length != expected) {
      throw ShouldlyTestFailureError(
        'Current length ${subject!.length} is not equal to $expected.',
      );
    }
  }

  return IterableAssertions(subject);
}