Search Results for

    Show / Hide Table of Contents

    Class ConstraintResult

    Contains the result of matching a Constraint against an actual value.

    Inheritance
    object
    ConstraintResult
    CollectionEquivalentConstraintResult
    EqualConstraintResult
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: NUnit.Framework.Constraints
    Assembly: nunit.framework.dll
    Syntax
    public class ConstraintResult

    Constructors

    View Source

    ConstraintResult(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.

    View Source

    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.

    View Source

    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 Source

    ActualValue

    The actual value that was passed to the ApplyTo<TActual>(TActual) method.

    Declaration
    public object? ActualValue { get; }
    Property Value
    Type Description
    object
    View Source

    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
    View Source

    IsSuccess

    True if actual value meets the Constraint criteria otherwise false.

    Declaration
    public virtual bool IsSuccess { get; }
    Property Value
    Type Description
    bool
    View Source

    Name

    Display friendly name of the constraint.

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    string
    View Source

    Status

    Gets and sets the ResultStatus for this result.

    Declaration
    public ConstraintStatus Status { get; set; }
    Property Value
    Type Description
    ConstraintStatus

    Methods

    View Source

    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.

    Declaration
    public virtual void WriteActualValueTo(MessageWriter writer)
    Parameters
    Type Name Description
    MessageWriter writer

    The writer on which the actual value is displayed

    View Source

    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

    View Source

    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

    • View Source
    In this article
    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0