Compound Constraints (NUnit 2.4)
Compound constraints are used to combine other constraints in various ways.
| Syntax Helper | Constructor | Operation |
|---|---|---|
| Is.Not... | NotConstraint( Constraint ) | Negates or reverses the effect of a constraint |
| Is.All... | AllItemsConstraint( Constraint ) | Negates or reverses the effect of a constraint |
| Constraint & Constraint | AndConstraint( Constraint, Constraint ) | Negates or reverses the effect of a constraint |
| Constraint | Constraint | OrConstraint( Constraint, Constraint ) | Negates or reverses the effect of a constraint |
Examples of Use
Assert.That( 2 + 2, Is.Not.EqualTo( 5 );
Assert.That( new int[] { 1, 2, 3 }, Is.All.GreaterThan( 0 ) );
Assert.That( 2.3, Is.GreaterThan( 2.0 ) & Is.LessThan( 3.0 ) );
Assert.That( 3, Is.LessThan( 5 ) | Is.GreaterThan( 10 ) );
// Using inheritance
Expect( 2 + 2, Not.EqualTo( 5 ) );
Expect( 2.3, GreaterThan( 2.0 ) & LessThan( 3.0 ) );
