Class ConstraintResult
Contains the result of matching a Constraint against an actual value.
Inherited Members
Namespace: NUnit.Framework.Constraints
Assembly: nunit.framework.dll
Syntax
public class ConstraintResult
Constructors
View SourceConstraintResult(IConstraint, object?)
Constructs a ConstraintResult for a particular Constraint.
Declaration
public ConstraintResult(IConstraint constraint, object? actualValue)
Parameters
Type | Name | Description |
---|---|---|
IConstraint | constraint | The Constraint to which this result applies. |
object | actualValue | The actual value to which the Constraint was applied. |
ConstraintResult(IConstraint, object?, ConstraintStatus)
Constructs a ConstraintResult for a particular Constraint.
Declaration
public ConstraintResult(IConstraint constraint, object? actualValue, ConstraintStatus status)
Parameters
Type | Name | Description |
---|---|---|
IConstraint | constraint | The Constraint to which this result applies. |
object | actualValue | The actual value to which the Constraint was applied. |
ConstraintStatus | status | The status of the new ConstraintResult. |
ConstraintResult(IConstraint, object?, bool)
Constructs a ConstraintResult for a particular Constraint.
Declaration
public ConstraintResult(IConstraint constraint, object? actualValue, bool isSuccess)
Parameters
Type | Name | Description |
---|---|---|
IConstraint | constraint | The Constraint to which this result applies. |
object | actualValue | The actual value to which the Constraint was applied. |
bool | isSuccess | If true, applies a status of Success to the result, otherwise Failure. |
Properties
View SourceActualValue
The actual value that was passed to the ApplyTo<TActual>(TActual) method.
Declaration
public object? ActualValue { get; }
Property Value
Type | Description |
---|---|
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.
Declaration
public string Description { get; }
Property Value
Type | Description |
---|---|
string |
IsSuccess
True if actual value meets the Constraint criteria otherwise false.
Declaration
public virtual bool IsSuccess { get; }
Property Value
Type | Description |
---|---|
bool |
Name
Display friendly name of the constraint.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string |
Status
Gets and sets the ResultStatus for this result.
Declaration
public ConstraintStatus Status { get; set; }
Property Value
Type | Description |
---|---|
ConstraintStatus |
Methods
View SourceWriteActualValueTo(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.
Declaration
public virtual void WriteActualValueTo(MessageWriter writer)
Parameters
Type | Name | Description |
---|---|---|
MessageWriter | writer | The writer on which the actual value is displayed |
WriteAdditionalLinesTo(MessageWriter)
Write some additional failure message.
Declaration
public virtual void WriteAdditionalLinesTo(MessageWriter writer)
Parameters
Type | Name | Description |
---|---|---|
MessageWriter | writer | The MessageWriter on which to display the message |
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 occurred, can override this.
Declaration
public virtual void WriteMessageTo(MessageWriter writer)
Parameters
Type | Name | Description |
---|---|---|
MessageWriter | writer | The MessageWriter on which to display the message |