IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
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. More...
Public Member Functions | |
EqualConstraint (object expected) | |
Initializes a new instance of the EqualConstraint class. More... | |
EqualConstraint | Within (object amount) |
Flag the constraint to use a tolerance when determining equality. More... | |
EqualConstraint | Using (IComparer comparer) |
Flag the constraint to use the supplied IComparer object. More... | |
EqualConstraint | Using< T > (IComparer< T > comparer) |
Flag the constraint to use the supplied IComparer object. More... | |
EqualConstraint | Using< T > (Comparison< T > comparer) |
Flag the constraint to use the supplied Comparison object. More... | |
EqualConstraint | Using (IEqualityComparer comparer) |
Flag the constraint to use the supplied IEqualityComparer object. More... | |
EqualConstraint | Using< T > (IEqualityComparer< T > comparer) |
Flag the constraint to use the supplied IEqualityComparer object. More... | |
override ConstraintResult | ApplyTo< TActual > (TActual actual) |
Test whether the constraint is satisfied by a given value More... | |
![]() | |
virtual ConstraintResult | ApplyTo< TActual > (ActualValueDelegate< TActual > del) |
Applies the constraint to an ActualValueDelegate that returns the value to be tested. The default implementation simply evaluates the delegate but derived classes may override it to provide for delayed processing. More... | |
virtual ConstraintResult | ApplyTo< TActual > (ref TActual actual) |
Test whether the constraint is satisfied by a given reference. The default implementation simply dereferences the value but derived classes may override it to provide for delayed processing. More... | |
override string | ToString () |
Default override of ToString returns the constraint DisplayName followed by any arguments within angle brackets. More... | |
DelayedConstraint | After (int delayInMilliseconds) |
Returns a DelayedConstraint with the specified delay time. More... | |
DelayedConstraint | After (int delayInMilliseconds, int pollingInterval) |
Returns a DelayedConstraint with the specified delay time and polling interval. More... | |
Properties | |
Tolerance | Tolerance [get] |
Gets the tolerance for this comparison. More... | |
bool | CaseInsensitive [get] |
Gets a value indicating whether to compare case insensitive. More... | |
bool | ClipStrings [get, private set] |
Gets a value indicating whether or not to clip strings. More... | |
IList < NUnitEqualityComparer.FailurePoint > | FailurePoints [get] |
Gets the failure points. More... | |
EqualConstraint | IgnoreCase [get] |
Flag the constraint to ignore case and return self. More... | |
EqualConstraint | NoClip [get] |
Flag the constraint to suppress string clipping and return self. More... | |
EqualConstraint | AsCollection [get] |
Flag the constraint to compare arrays as collections and return self. More... | |
EqualConstraint | WithSameOffset [get] |
Flags the constraint to include DateTimeOffset.Offset property in comparison of two DateTimeOffset values. More... | |
EqualConstraint | Ulps [get] |
Switches the .Within() modifier to interpret its tolerance as a distance in representable _values (see remarks). More... | |
EqualConstraint | Percent [get] |
Switches the .Within() modifier to interpret its tolerance as a percentage that the actual _values is allowed to deviate from the expected value. More... | |
EqualConstraint | Days [get] |
Causes the tolerance to be interpreted as a TimeSpan in days. More... | |
EqualConstraint | Hours [get] |
Causes the tolerance to be interpreted as a TimeSpan in hours. More... | |
EqualConstraint | Minutes [get] |
Causes the tolerance to be interpreted as a TimeSpan in minutes. More... | |
EqualConstraint | Seconds [get] |
Causes the tolerance to be interpreted as a TimeSpan in seconds. More... | |
EqualConstraint | Milliseconds [get] |
Causes the tolerance to be interpreted as a TimeSpan in milliseconds. More... | |
EqualConstraint | Ticks [get] |
Causes the tolerance to be interpreted as a TimeSpan in clock ticks. More... | |
override string | Description [get] |
The Description of what this constraint tests, for use in messages and in the ConstraintResult. More... | |
![]() | |
string | DisplayName [get, protected set] |
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. More... | |
virtual string | Description [get, protected set] |
The Description of what this constraint tests, for use in messages and in the ConstraintResult. More... | |
object[] | Arguments [get, private set] |
Arguments provided to this Constraint, for use in formatting the description. More... | |
ConstraintBuilder | Builder [get, set] |
The ConstraintBuilder holding this constraint More... | |
ConstraintExpression | And [get] |
Returns a ConstraintExpression by appending And to the current constraint. More... | |
ConstraintExpression | With [get] |
Returns a ConstraintExpression by appending And to the current constraint. More... | |
ConstraintExpression | Or [get] |
Returns a ConstraintExpression by appending Or to the current constraint. More... | |
![]() | |
string | DisplayName [get] |
The display name of this Constraint for use by ToString(). More... | |
string | Description [get] |
The Description of what this constraint tests, for use in messages and in the ConstraintResult. More... | |
object[] | Arguments [get] |
Arguments provided to this Constraint, for use in formatting the description. More... | |
ConstraintBuilder | Builder [get, set] |
The ConstraintBuilder holding this constraint More... | |
Private Member Functions | |
void | AdjustArgumentIfNeeded< T > (ref T arg) |
Private Attributes | |
readonly object | _expected |
Tolerance | _tolerance = Tolerance.Default |
NUnitEqualityComparer | _comparer = new NUnitEqualityComparer() |
NUnitEqualityComparer used to test equality. More... | |
Additional Inherited Members | |
![]() | |
static Constraint | operator& (Constraint left, Constraint right) |
This operator creates a constraint that is satisfied only if both argument constraints are satisfied. More... | |
static Constraint | operator| (Constraint left, Constraint right) |
This operator creates a constraint that is satisfied if either of the argument constraints is satisfied. More... | |
static Constraint | operator! (Constraint constraint) |
This operator creates a constraint that is satisfied if the argument constraint is not satisfied. More... | |
![]() | |
Constraint (params object[] args) | |
Construct a constraint with optional arguments More... | |
virtual string | GetStringRepresentation () |
Returns the string representation of this constraint More... | |
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.
|
inline |
Initializes a new instance of the EqualConstraint class.
expected | The expected value. |
|
inline |
Flag the constraint to use a tolerance when determining equality.
amount | Tolerance value to be used |
References NUnit.Framework.Constraints.Tolerance.IsUnsetOrDefault.
Referenced by NUnit.Framework.Tests.AssertSyntaxTests.AllItemsTests(), NUnit.Framework.Tests.AssertSyntaxTests.EqualityTestsWithTolerance(), NUnit.Framework.Tests.AssertSyntaxTests.EqualityTestsWithTolerance_MixedFloatAndDouble(), NUnit.Framework.Tests.AssertSyntaxTests.EqualityTestsWithTolerance_MixingTypesGenerally(), NUnit.Framework.Constraints.EqualConstraintTests.FloatingPointEquality.ErrorWithPercentAndUlpsToleranceModes(), NUnit.Framework.Constraints.EqualConstraintTests.FloatingPointEquality.ErrorWithUlpsAndPercentToleranceModes(), NUnit.Framework.Constraints.NotConstraintTests.NotHonorsTolerance(), NUnit.Framework.Constraints.PropertyTest.PropertyEqualToValueWithTolerance(), and NUnit.Framework.Tests.Constraints.ToleranceTests.TestWithinCanOnlyBeUsedOnce().
|
inline |
Flag the constraint to use the supplied IComparer object.
comparer | The IComparer object to use. |
References NUnit.Framework.Constraints.NUnitEqualityComparer.ExternalComparers, and NUnit.Framework.Constraints.EqualityAdapter.For().
Referenced by NUnit.Framework.CollectionAssert.AreEqual(), and NUnit.Framework.CollectionAssert.AreNotEqual().
|
inline |
Flag the constraint to use the supplied IComparer object.
comparer | The IComparer object to use. |
References NUnit.Framework.Constraints.NUnitEqualityComparer.ExternalComparers, and NUnit.Framework.Constraints.EqualityAdapter.For().
|
inline |
Flag the constraint to use the supplied Comparison object.
comparer | The IComparer object to use. |
References NUnit.Framework.Constraints.NUnitEqualityComparer.ExternalComparers, and NUnit.Framework.Constraints.EqualityAdapter.For().
|
inline |
Flag the constraint to use the supplied IEqualityComparer object.
comparer | The IComparer object to use. |
References NUnit.Framework.Constraints.NUnitEqualityComparer.ExternalComparers, and NUnit.Framework.Constraints.EqualityAdapter.For().
|
inline |
Flag the constraint to use the supplied IEqualityComparer object.
comparer | The IComparer object to use. |
References NUnit.Framework.Constraints.NUnitEqualityComparer.ExternalComparers, and NUnit.Framework.Constraints.EqualityAdapter.For().
|
inlinevirtual |
Test whether the constraint is satisfied by a given value
actual | The value to be tested |
Implements NUnit.Framework.Constraints.Constraint.
References NUnit.Framework.Constraints.NUnitEqualityComparer.AreEqual().
|
inlineprivate |
|
private |
|
private |
|
private |
NUnitEqualityComparer used to test equality.
|
get |
Gets the tolerance for this comparison.
The tolerance.
Referenced by NUnit.Framework.Constraints.EqualConstraintResult.EqualConstraintResult().
|
get |
Gets a value indicating whether to compare case insensitive.
true
if comparing case insensitive; otherwise, false
.
Referenced by NUnit.Framework.Constraints.EqualConstraintResult.EqualConstraintResult().
|
getprivate set |
Gets a value indicating whether or not to clip strings.
true
if set to clip strings otherwise, false
.
Referenced by NUnit.Framework.Constraints.EqualConstraintResult.EqualConstraintResult().
|
get |
Gets the failure points.
The failure points.
Referenced by NUnit.Framework.Constraints.EqualConstraintResult.EqualConstraintResult().
|
get |
Flag the constraint to ignore case and return self.
Referenced by NUnit.Framework.Tests.AssertSyntaxTests.EqualIgnoringCaseTests(), and NUnit.Framework.Constraints.NotConstraintTests.NotHonorsIgnoreCaseUsingPrefixNotation().
|
get |
Flag the constraint to suppress string clipping and return self.
Referenced by NUnit.Framework.Syntax.MixedOperatorOverrides.ComplexTests(), NUnit.Framework.Syntax.SyntaxTest.SupportedByConstraintBuilder(), NUnit.Framework.Syntax.SyntaxTest.SupportedByInheritedSyntax(), and NUnit.Framework.Syntax.SyntaxTest.SupportedByStaticSyntax().
|
get |
Flag the constraint to compare arrays as collections and return self.
|
get |
Flags the constraint to include DateTimeOffset.Offset property in comparison of two DateTimeOffset values.
Using this modifier does not allow to use the Within constraint modifier.
|
get |
Switches the .Within() modifier to interpret its tolerance as a distance in representable _values (see 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.
Referenced by NUnit.Framework.Constraints.EqualConstraintTests.FloatingPointEquality.ErrorWithPercentAndUlpsToleranceModes(), and NUnit.Framework.Constraints.EqualConstraintTests.FloatingPointEquality.ErrorWithUlpsAndPercentToleranceModes().
|
get |
Switches the .Within() modifier to interpret its tolerance as a percentage that the actual _values is allowed to deviate from the expected value.
Referenced by NUnit.Framework.Constraints.EqualConstraintTests.FloatingPointEquality.ErrorWithPercentAndUlpsToleranceModes(), and NUnit.Framework.Constraints.EqualConstraintTests.FloatingPointEquality.ErrorWithUlpsAndPercentToleranceModes().
|
get |
Causes the tolerance to be interpreted as a TimeSpan in days.
|
get |
Causes the tolerance to be interpreted as a TimeSpan in hours.
|
get |
Causes the tolerance to be interpreted as a TimeSpan in minutes.
|
get |
Causes the tolerance to be interpreted as a TimeSpan in seconds.
|
get |
Causes the tolerance to be interpreted as a TimeSpan in milliseconds.
|
get |
Causes the tolerance to be interpreted as a TimeSpan in clock ticks.
Referenced by NUnit.Framework.Constraints.EqualConstraintTests.DateTimeEquality.CanMatchDatesWithinTicks(), and NUnit.Framework.Constraints.EqualConstraintTests.DateTimeOffSetEquality.CanMatchDatesWithinTicks().
|
get |
The Description of what this constraint tests, for use in messages and in the ConstraintResult.