Class Tolerance
- Namespace
- NUnit.Framework.Constraints
- Assembly
- nunit.framework.dll
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.
public sealed class Tolerance
- Inheritance
-
Tolerance
- Inherited Members
Constructors
Tolerance(object)
Constructs a linear tolerance of a specified amount
public Tolerance(object amount)
Parameters
amount
object
Fields
Default
Returns a default Tolerance object, equivalent to a default matching rules.
public static readonly Tolerance Default
Field Value
Exact
Returns an empty Tolerance object, equivalent to an exact match.
public static readonly Tolerance Exact
Field Value
Properties
Amount
Gets the magnitude of the current Tolerance instance.
public object Amount { get; }
Property Value
Days
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of days.
public Tolerance Days { get; }
Property Value
HasVariance
Returns true if the current tolerance varies from exact and default. Indicating tolerance needs processing.
public bool HasVariance { get; }
Property Value
Hours
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of hours.
public Tolerance Hours { get; }
Property Value
IsUnsetOrDefault
Returns true if the current tolerance has not been set or is using the default.
public bool IsUnsetOrDefault { get; }
Property Value
Milliseconds
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of milliseconds.
public Tolerance Milliseconds { get; }
Property Value
Minutes
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of minutes.
public Tolerance Minutes { get; }
Property Value
Mode
Gets the ToleranceMode for the current Tolerance
public ToleranceMode Mode { get; }
Property Value
Percent
Returns a new tolerance, using the current amount as a percentage.
public Tolerance Percent { get; }
Property Value
Seconds
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of seconds.
public Tolerance Seconds { get; }
Property Value
Ticks
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of clock ticks.
public Tolerance Ticks { get; }
Property Value
Ulps
Returns a new tolerance, using the current amount in Ulps
public Tolerance Ulps { get; }
Property Value
Methods
ApplyToValue(object)
Apply the tolerance to an expected value and return a Tolerance.Range that represents the acceptable values.
public Tolerance.Range ApplyToValue(object value)
Parameters
value
object
Returns
ToString()
Returns a string that represents the current object.
public override string? ToString()
Returns
- string
A string that represents the current object.