Class EqualTimeBaseConstraint<T>
EqualConstraint 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.
Inherited Members
Namespace: NUnit.Framework.Constraints
Assembly: nunit.framework.dll
Syntax
public class EqualTimeBaseConstraint<T> : Constraint, IConstraint, IResolveConstraint where T : struct, IEquatable<T>, IComparable<T>
Type Parameters
| Name | Description |
|---|---|
| T |
Constructors
View SourceEqualTimeBaseConstraint(T, Func<T, long>)
Initializes a new instance of the EqualConstraint class.
Declaration
public EqualTimeBaseConstraint(T expected, Func<T, long> getTicks)
Parameters
| Type | Name | Description |
|---|---|---|
| T | expected | The expected value. |
| Func<T, long> | getTicks | Method to extract the Ticks from an instance of |
Properties
View SourceDescription
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
View SourceExpected
Gets the expected value.
Declaration
public T Expected { get; }
Property Value
| Type | Description |
|---|---|
| T |
Methods
View SourceApplyTo(T)
Test whether the constraint is satisfied by a given value
Declaration
public virtual 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 |
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
View SourceWithin(double)
Flag the constraint to use a tolerance when determining equality.
Declaration
public EqualTimeBasedConstraintWithNumericTolerance<T> Within(double amount)
Parameters
| Type | Name | Description |
|---|---|---|
| double | amount | Tolerance value to be used |
Returns
| Type | Description |
|---|---|
| EqualTimeBasedConstraintWithNumericTolerance<T> | Self. |
Within(TimeSpan)
Flag the constraint to use a tolerance when determining equality.
Declaration
public EqualTimeBasedConstraintWithTimeSpanTolerance<T> Within(TimeSpan amount)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | amount | Tolerance value to be used |
Returns
| Type | Description |
|---|---|
| EqualTimeBasedConstraintWithTimeSpanTolerance<T> | Self. |