Skip to content

ExactCountConstraint

Charlie Poole edited this page Jan 31, 2016 · 8 revisions

ExactCountConstraint applies a constraint to each item in an IEnumerable, succeeding if the specified number of items succeed. An exception is thrown if the actual value passed does not implement IEnumerable.

Constructor

ExactCountConstraint(int expectedCount, Constraint itemConstraint)

Syntax

Has.Exactly(int expectedCount)...

Examples of Use

int[] array = new int[] { 1, 2, 3 };
Assert.That( array, Has.Exactly(1).EqualTo(3) );
Assert.That( array, Has.Exactly(2).GreaterThan(1) );
Assert.That( array, Has.Exactly(3).LessThan(100) );
Clone this wiki locally