Search Results for

    Show / Hide Table of Contents

    Class EqualNumericWithoutUsingConstraint<T>

    EqualNumericConstraint is able to compare an actual value with the expected value provided in its constructor. Two objects are considered equal if both are null, or if both have the same value. NUnit has special semantics for some object types.

    Inheritance
    object
    Constraint
    EqualNumericWithoutUsingConstraint<T>
    EqualNumericConstraint<T>
    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.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 class EqualNumericWithoutUsingConstraint<T> : Constraint, IConstraint, IResolveConstraint where T : struct
    Type Parameters
    Name Description
    T

    Constructors

    View Source

    EqualNumericWithoutUsingConstraint(T)

    Initializes a new instance of the EqualConstraint class.

    Declaration
    public EqualNumericWithoutUsingConstraint(T expected)
    Parameters
    Type Name Description
    T expected

    The expected value.

    Remarks

    Marked internal to prevent external instantiation with non-supported types.

    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

    DisplayName

    The display name of this Constraint for use by ToString(). The default value is the name of the constraint with trailing "Constraint" removed. Derived classes may set this to another name in their constructors.

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

    Expected

    The expected value.

    Declaration
    public T Expected { get; }
    Property Value
    Type Description
    T
    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 EqualNumericWithoutUsingConstraint<T> Percent { get; }
    Property Value
    Type Description
    EqualNumericWithoutUsingConstraint<T>

    Self

    View Source

    Tolerance

    Gets the tolerance for this comparison.

    Declaration
    public Tolerance Tolerance { get; }
    Property Value
    Type Description
    Tolerance

    The tolerance.

    View Source

    Ulps

    Switches the .Within() modifier to interpret its tolerance as a distance in representable values (see remarks).

    Declaration
    public EqualNumericWithoutUsingConstraint<T> Ulps { get; }
    Property Value
    Type Description
    EqualNumericWithoutUsingConstraint<T>

    Self.

    Remarks

    Ulp stands for "unit in the last place" and describes the minimum amount a given value can change. For any integers, an ulp is 1 whole digit. For floating point values, the accuracy of which is better for smaller numbers and worse for larger numbers, an ulp depends on the size of the number. Using ulps for comparison of floating point results instead of fixed tolerances is safer because it will automatically compensate for the added inaccuracy of larger numbers.

    Methods

    View Source

    ApplyTo(T)

    Test whether the constraint is satisfied by a given value

    Declaration
    public ConstraintResult ApplyTo(T actual)
    Parameters
    Type Name Description
    T actual

    The value to be tested

    Returns
    Type Description
    ConstraintResult

    True for success, false for failure

    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

    True for success, false for failure

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

    Within(T)

    Flag the constraint to use a tolerance when determining equality.

    Declaration
    public EqualNumericWithoutUsingConstraint<T> Within(T amount)
    Parameters
    Type Name Description
    T amount

    Tolerance value to be used

    Returns
    Type Description
    EqualNumericWithoutUsingConstraint<T>

    Self.

    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