ConditionConstraints test a specific condition and are named for the condition they test. They verify that the actual value satisfies the condition. The following condition helpers are provided.
Syntax Helper | Constructor | Operation |
---|---|---|
Is.Null | EqualConstraint( null ) | tests for null |
Is.True | EqualConstraint( true ) | tests for true |
Is.False | EqualConstraint( false ) | tests for false |
Is.NaN | EqualConstraint( double.NaN ) EqualConstraint( float.NaN ) | tests for floating NaN |
Is.Empty | EmptyConstraint() | tests for empty string or collection |
Is.Unique | UniqueItemsConstraint() | tests that collection contains unique items |
Assert.That( anObject, Is.Null ); Assert.That( anObject, Is.Not.Null ); Assert.That( condition, Is.True ); Assert.That( condition, Is.False ); Assert.That( aDouble, Is.NaN ); Assert.That( aDouble, Is.Not.NaN ); Assert.That( aString, Is.Empty ); Assert.That( collection, Is.Empty ); Assert.That( collection, Is.Unique ); // Using inheritance Expect( aDouble, NaN ); Expect( collection, Unique );