Legacy Documentation. View NUnit 3 Documentation

Condition Constraints (NUnit 2.4)

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 HelperConstructorOperation
Is.NullEqualConstraint( null )tests for null
Is.TrueEqualConstraint( true )tests for true
Is.FalseEqualConstraint( false )tests for false
Is.NaNEqualConstraint( double.NaN )
EqualConstraint( float.NaN )
tests for floating NaN
Is.EmptyEmptyConstraint()tests for empty string or collection
Is.UniqueUniqueItemsConstraint()tests that collection contains unique items

Examples

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 );