Search Results for

    Show / Hide Table of Contents

    Class Tolerance

    The Tolerance class generalizes the notion of a tolerance within which an equality test succeeds. Normally, it is used with numeric types, but it can be used with any type that supports taking a difference between two objects and comparing that difference to a value.

    Inheritance
    object
    Tolerance
    Inherited Members
    object.GetType()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: NUnit.Framework.Constraints
    Assembly: nunit.framework.dll
    Syntax
    public sealed class Tolerance

    Constructors

    View Source

    Tolerance(object)

    Constructs a linear tolerance of a specified amount

    Declaration
    public Tolerance(object amount)
    Parameters
    Type Name Description
    object amount

    Fields

    View Source

    Default

    Returns a default Tolerance object, equivalent to a default matching rules.

    Declaration
    public static readonly Tolerance Default
    Field Value
    Type Description
    Tolerance
    View Source

    Exact

    Returns an empty Tolerance object, equivalent to an exact match.

    Declaration
    public static readonly Tolerance Exact
    Field Value
    Type Description
    Tolerance

    Properties

    View Source

    Amount

    Gets the magnitude of the current Tolerance instance.

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

    Days

    Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of days.

    Declaration
    public Tolerance Days { get; }
    Property Value
    Type Description
    Tolerance
    View Source

    HasVariance

    Returns true if the current tolerance varies from exact and default. Indicating tolerance needs processing.

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

    Hours

    Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of hours.

    Declaration
    public Tolerance Hours { get; }
    Property Value
    Type Description
    Tolerance
    View Source

    IsUnsetOrDefault

    Returns true if the current tolerance has not been set or is using the default.

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

    Milliseconds

    Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of milliseconds.

    Declaration
    public Tolerance Milliseconds { get; }
    Property Value
    Type Description
    Tolerance
    View Source

    Minutes

    Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of minutes.

    Declaration
    public Tolerance Minutes { get; }
    Property Value
    Type Description
    Tolerance
    View Source

    Mode

    Gets the ToleranceMode for the current Tolerance

    Declaration
    public ToleranceMode Mode { get; }
    Property Value
    Type Description
    ToleranceMode
    View Source

    Percent

    Returns a new tolerance, using the current amount as a percentage.

    Declaration
    public Tolerance Percent { get; }
    Property Value
    Type Description
    Tolerance
    View Source

    Seconds

    Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of seconds.

    Declaration
    public Tolerance Seconds { get; }
    Property Value
    Type Description
    Tolerance
    View Source

    Ticks

    Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of clock ticks.

    Declaration
    public Tolerance Ticks { get; }
    Property Value
    Type Description
    Tolerance
    View Source

    Ulps

    Returns a new tolerance, using the current amount in Ulps

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

    Methods

    View Source

    ApplyToValue(object)

    Apply the tolerance to an expected value and return a Tolerance.Range that represents the acceptable values.

    Declaration
    public Tolerance.Range ApplyToValue(object value)
    Parameters
    Type Name Description
    object value
    Returns
    Type Description
    Tolerance.Range
    View Source

    ToString()

    Returns a string that represents the current object.

    Declaration
    public override string? ToString()
    Returns
    Type Description
    string

    A string that represents the current object.

    Overrides
    object.ToString()
    • 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