Class ConstraintResult
- Namespace
- NUnit.Framework.Constraints
- Assembly
- nunit.framework.dll
Contain the result of matching a Constraint against an actual value.
public class ConstraintResult
- Inheritance
-
ConstraintResult
- Derived
- Inherited Members
Constructors
ConstraintResult(IConstraint, object)
Constructs a ConstraintResult for a particular Constraint.
public ConstraintResult(IConstraint constraint, object actualValue)
Parameters
constraint
IConstraintThe Constraint to which this result applies.
actualValue
objectThe actual value to which the Constraint was applied.
ConstraintResult(IConstraint, object, ConstraintStatus)
Constructs a ConstraintResult for a particular Constraint.
public ConstraintResult(IConstraint constraint, object actualValue, ConstraintStatus status)
Parameters
constraint
IConstraintThe Constraint to which this result applies.
actualValue
objectThe actual value to which the Constraint was applied.
status
ConstraintStatusThe status of the new ConstraintResult.
ConstraintResult(IConstraint, object, bool)
Constructs a ConstraintResult for a particular Constraint.
public ConstraintResult(IConstraint constraint, object actualValue, bool isSuccess)
Parameters
constraint
IConstraintThe Constraint to which this result applies.
actualValue
objectThe actual value to which the Constraint was applied.
isSuccess
boolIf true, applies a status of Success to the result, otherwise Failure.
Properties
ActualValue
The actual value that was passed to the ApplyTo<TActual>(TActual) method.
public object ActualValue { get; }
Property Value
Description
Description of the constraint may be affected by the state the constraint had when ApplyTo<TActual>(TActual) was performed against the actual value.
public string Description { get; }
Property Value
IsSuccess
True if actual value meets the Constraint criteria otherwise false.
public virtual bool IsSuccess { get; }
Property Value
Name
Display friendly name of the constraint.
public string Name { get; }
Property Value
Status
Gets and sets the ResultStatus for this result.
public ConstraintStatus Status { get; set; }
Property Value
Methods
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.
public virtual void WriteActualValueTo(MessageWriter writer)
Parameters
writer
MessageWriterThe writer on which the actual value is displayed
WriteMessageTo(MessageWriter)
Write the failure message to the MessageWriter provided as an argument. The default implementation simply passes the result 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.
public virtual void WriteMessageTo(MessageWriter writer)
Parameters
writer
MessageWriterThe MessageWriter on which to display the message