<PackageReference Include="NUnit" Version="2.6.4" />

Constraint

public abstract class Constraint : IResolveConstraint
The Constraint class is the base of all built-in constraints within NUnit. It provides the operator overloads used to combine constraints.
protected static object UNSET

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

protected object actual

The actual value being tested against a constraint

public ConstraintExpression And { get; }

Returns a ConstraintExpression by appending And to the current constraint.

protected string DisplayName { get; protected set; }

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.

public ConstraintExpression Or { get; }

Returns a ConstraintExpression by appending Or to the current constraint.

public ConstraintExpression With { get; }

Returns a ConstraintExpression by appending And to the current constraint.

protected Constraint()

Construct a constraint with no arguments

protected Constraint(object arg)

Construct a constraint with one argument

protected Constraint(object arg1, object arg2)

Construct a constraint with two arguments

public static Constraint op_BitwiseAnd(Constraint left, Constraint right)

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

public static Constraint op_BitwiseOr(Constraint left, Constraint right)

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

public static Constraint op_LogicalNot(Constraint constraint)

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

public DelayedConstraint After(int delayInMilliseconds)

Returns a DelayedConstraint with the specified delay time.

public DelayedConstraint After(int delayInMilliseconds, int pollingInterval)

Returns a DelayedConstraint with the specified delay time and polling interval.

protected virtual string GetStringRepresentation()

Returns the string representation of this constraint

public abstract bool Matches(object actual)

Test whether the constraint is satisfied by a given value

public virtual bool Matches<T>(ActualValueDelegate<T> del)

Test whether the constraint is satisfied by an ActualValueDelegate that returns the value to be tested. The default implementation simply evaluates the delegate but derived classes may override it to provide for delayed processing.

public virtual bool Matches<T>(ref T actual)

Test whether the constraint is satisfied by a given reference. The default implementation simply dereferences the value but derived classes may override it to provide for delayed processing.

public virtual void WriteActualValueTo(MessageWriter writer)

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.

public abstract void WriteDescriptionTo(MessageWriter writer)

Write the constraint description to a MessageWriter

public virtual void WriteMessageTo(MessageWriter writer)

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.