Table of Contents

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 IConstraint

The Constraint to which this result applies.

actualValue object

The 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 IConstraint

The Constraint to which this result applies.

actualValue object

The actual value to which the Constraint was applied.

status ConstraintStatus

The 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 IConstraint

The Constraint to which this result applies.

actualValue object

The actual value to which the Constraint was applied.

isSuccess bool

If 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

object

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

string

IsSuccess

True if actual value meets the Constraint criteria otherwise false.

public virtual bool IsSuccess { get; }

Property Value

bool

Name

Display friendly name of the constraint.

public string Name { get; }

Property Value

string

Status

Gets and sets the ResultStatus for this result.

public ConstraintStatus Status { get; set; }

Property Value

ConstraintStatus

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 MessageWriter

The 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 MessageWriter

The MessageWriter on which to display the message