Search Results for

    Show / Hide Table of Contents

    Class ComparisonConstraint

    Abstract base class for constraints that compare values to determine if one is greater than, equal to or less than the other.

    Inheritance
    object
    Constraint
    ComparisonConstraint
    GreaterThanConstraint
    GreaterThanOrEqualConstraint
    LessThanConstraint
    LessThanOrEqualConstraint
    Implements
    IConstraint
    IResolveConstraint
    Inherited Members
    Constraint.ApplyTo<TActual>(ActualValueDelegate<TActual>)
    Constraint.ApplyTo<TActual>(ref TActual)
    Constraint.ApplyToAsync<TActual>(Func<Task<TActual>>)
    Constraint.GetTestObject<TActual>(ActualValueDelegate<TActual>)
    Constraint.ToString()
    Constraint.GetStringRepresentation(IEnumerable)
    Constraint.GetStringRepresentation()
    Constraint.After(int)
    Constraint.After(int, int)
    Constraint.DisplayName
    Constraint.Arguments
    Constraint.Builder
    Constraint.And
    Constraint.With
    Constraint.Or
    object.GetType()
    object.MemberwiseClone()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: NUnit.Framework.Constraints
    Assembly: nunit.framework.dll
    Syntax
    public abstract class ComparisonConstraint : Constraint, IConstraint, IResolveConstraint

    Constructors

    View Source

    ComparisonConstraint(object, string)

    Initializes a new instance of the ComparisonConstraint class.

    Declaration
    protected ComparisonConstraint(object expected, string comparisonText)
    Parameters
    Type Name Description
    object expected

    The value against which to make a comparison.

    string comparisonText

    The text indicating the type of comparison.

    Properties

    View Source

    Description

    The Description of what this constraint tests, for use in messages and in the ConstraintResult.

    Declaration
    public override string Description { get; }
    Property Value
    Type Description
    string
    Overrides
    Constraint.Description
    View Source

    Percent

    Switches the .Within() modifier to interpret its tolerance as a percentage that the actual values is allowed to deviate from the expected value.

    Declaration
    public ComparisonConstraint Percent { get; }
    Property Value
    Type Description
    ComparisonConstraint

    Self

    Methods

    View Source

    ApplyTo<TActual>(TActual)

    Test whether the constraint is satisfied by a given value

    Declaration
    public override ConstraintResult ApplyTo<TActual>(TActual actual)
    Parameters
    Type Name Description
    TActual actual

    The value to be tested

    Returns
    Type Description
    ConstraintResult

    A ConstraintResult

    Type Parameters
    Name Description
    TActual
    Overrides
    Constraint.ApplyTo<TActual>(TActual)
    View Source

    PerformComparison(ComparisonAdapter, object, object, Tolerance)

    Protected function overridden by derived class to actually perform the comparison

    Declaration
    protected abstract bool PerformComparison(ComparisonAdapter comparer, object actual, object expected, Tolerance tolerance)
    Parameters
    Type Name Description
    ComparisonAdapter comparer
    object actual
    object expected
    Tolerance tolerance
    Returns
    Type Description
    bool
    View Source

    Using(IComparer)

    Modifies the constraint to use an IComparer and returns self

    Declaration
    public ComparisonConstraint Using(IComparer comparer)
    Parameters
    Type Name Description
    IComparer comparer

    The comparer used for comparison tests

    Returns
    Type Description
    ComparisonConstraint

    A constraint modified to use the given comparer

    View Source

    Using<T>(IComparer<T>)

    Modifies the constraint to use an IComparer<T> and returns self

    Declaration
    public ComparisonConstraint Using<T>(IComparer<T> comparer)
    Parameters
    Type Name Description
    IComparer<T> comparer

    The comparer used for comparison tests

    Returns
    Type Description
    ComparisonConstraint

    A constraint modified to use the given comparer

    Type Parameters
    Name Description
    T
    View Source

    Using<T>(Comparison<T>)

    Modifies the constraint to use a Comparison<T> and returns self

    Declaration
    public ComparisonConstraint Using<T>(Comparison<T> comparer)
    Parameters
    Type Name Description
    Comparison<T> comparer

    The comparer used for comparison tests

    Returns
    Type Description
    ComparisonConstraint

    A constraint modified to use the given comparer

    Type Parameters
    Name Description
    T
    View Source

    Within(object)

    Set the tolerance for use in this comparison

    Declaration
    public ComparisonConstraint Within(object amount)
    Parameters
    Type Name Description
    object amount
    Returns
    Type Description
    ComparisonConstraint

    Implements

    IConstraint
    IResolveConstraint
    • 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