Constraint Class

Definition

The Constraint class is the base of all built-in constraints within NUnit. It provides the operator overloads used to combine constraints.

public abstract class Constraint : NUnit.Framework.Constraints.IResolveConstraint
type Constraint = class
    interface IResolveConstraint
Inheritance
Constraint
Derived
Implements

Constructors

Constraint()

Construct a constraint with no arguments

Constraint(Object, Object)

Construct a constraint with two arguments

Constraint(Object)

Construct a constraint with one argument

Fields

actual

The actual value being tested against a constraint

UNSET

Static UnsetObject used to detect derived constraints failing to set the actual value.

Properties

And

Returns a ConstraintExpression by appending And to the current constraint.

DisplayName

The display name of this Constraint for use by ToString(). The default value is the name of the constraint with trailing "Constraint" removed. Derived classes may set this to another name in their constructors.

Or

Returns a ConstraintExpression by appending Or to the current constraint.

With

Returns a ConstraintExpression by appending And to the current constraint.

Methods

After(Int32, Int32)
After(Int32)
GetStringRepresentation()
Matches(Object)

Test whether the constraint is satisfied by a given value

Matches<T>(ActualValueDelegate<T>)
Matches<T>(T)
ToString()

Default override of ToString returns the constraint DisplayName followed by any arguments within angle brackets.

WriteActualValueTo(MessageWriter)

Write the actual value for a failing constraint test to a MessageWriter. The default implementation simply writes the raw value of actual, leaving it to the writer to perform any formatting.

WriteDescriptionTo(MessageWriter)

Write the constraint description to a MessageWriter

WriteMessageTo(MessageWriter)

Write the failure message to the MessageWriter provided as an argument. The default implementation simply passes the constraint and the actual value to the writer, which then displays the constraint description and the value. Constraints that need to provide additional details, such as where the error occured can override this.

Operators

BitwiseAnd(Constraint, Constraint)

This operator creates a constraint that is satisfied only if both argument constraints are satisfied.

BitwiseOr(Constraint, Constraint)

This operator creates a constraint that is satisfied if either of the argument constraints is satisfied.

LogicalNot(Constraint)

This operator creates a constraint that is satisfied if the argument constraint is not satisfied.

Explicit Interface Implementations

IResolveConstraint.Resolve()

Applies to