IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
NUnit.Framework.Constraints.EqualConstraint Class Reference

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...

+ Inheritance diagram for NUnit.Framework.Constraints.EqualConstraint:
+ Collaboration diagram for NUnit.Framework.Constraints.EqualConstraint:

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...
 
- Public Member Functions inherited from NUnit.Framework.Constraints.Constraint
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...
 
- Properties inherited from NUnit.Framework.Constraints.Constraint
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...
 
- Properties inherited from NUnit.Framework.Constraints.IConstraint
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 Public Member Functions inherited from NUnit.Framework.Constraints.Constraint
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...
 
- Protected Member Functions inherited from NUnit.Framework.Constraints.Constraint
 Constraint (params object[] args)
 Construct a constraint with optional arguments More...
 
virtual string GetStringRepresentation ()
 Returns the string representation of this constraint More...
 

Detailed Description

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.

Constructor & Destructor Documentation

NUnit.Framework.Constraints.EqualConstraint.EqualConstraint ( object  expected)
inline

Initializes a new instance of the EqualConstraint class.

Parameters
expectedThe expected value.

Member Function Documentation

EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Using ( IComparer  comparer)
inline

Flag the constraint to use the supplied IComparer object.

Parameters
comparerThe IComparer object to use.
Returns
Self.

References NUnit.Framework.Constraints.NUnitEqualityComparer.ExternalComparers, and NUnit.Framework.Constraints.EqualityAdapter.For().

Referenced by NUnit.Framework.CollectionAssert.AreEqual(), and NUnit.Framework.CollectionAssert.AreNotEqual().

EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Using< T > ( IComparer< T >  comparer)
inline

Flag the constraint to use the supplied IComparer object.

Parameters
comparerThe IComparer object to use.
Returns
Self.

References NUnit.Framework.Constraints.NUnitEqualityComparer.ExternalComparers, and NUnit.Framework.Constraints.EqualityAdapter.For().

EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Using< T > ( Comparison< T >  comparer)
inline

Flag the constraint to use the supplied Comparison object.

Parameters
comparerThe IComparer object to use.
Returns
Self.

References NUnit.Framework.Constraints.NUnitEqualityComparer.ExternalComparers, and NUnit.Framework.Constraints.EqualityAdapter.For().

EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Using ( IEqualityComparer  comparer)
inline

Flag the constraint to use the supplied IEqualityComparer object.

Parameters
comparerThe IComparer object to use.
Returns
Self.

References NUnit.Framework.Constraints.NUnitEqualityComparer.ExternalComparers, and NUnit.Framework.Constraints.EqualityAdapter.For().

EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Using< T > ( IEqualityComparer< T >  comparer)
inline

Flag the constraint to use the supplied IEqualityComparer object.

Parameters
comparerThe IComparer object to use.
Returns
Self.

References NUnit.Framework.Constraints.NUnitEqualityComparer.ExternalComparers, and NUnit.Framework.Constraints.EqualityAdapter.For().

override ConstraintResult NUnit.Framework.Constraints.EqualConstraint.ApplyTo< TActual > ( TActual  actual)
inlinevirtual

Test whether the constraint is satisfied by a given value

Parameters
actualThe value to be tested
Returns
True for success, false for failure

Implements NUnit.Framework.Constraints.Constraint.

References NUnit.Framework.Constraints.NUnitEqualityComparer.AreEqual().

void NUnit.Framework.Constraints.EqualConstraint.AdjustArgumentIfNeeded< T > ( ref T  arg)
inlineprivate

Member Data Documentation

readonly object NUnit.Framework.Constraints.EqualConstraint._expected
private
Tolerance NUnit.Framework.Constraints.EqualConstraint._tolerance = Tolerance.Default
private
NUnitEqualityComparer NUnit.Framework.Constraints.EqualConstraint._comparer = new NUnitEqualityComparer()
private

NUnitEqualityComparer used to test equality.

Property Documentation

Tolerance NUnit.Framework.Constraints.EqualConstraint.Tolerance
get

Gets the tolerance for this comparison.

The tolerance.

Referenced by NUnit.Framework.Constraints.EqualConstraintResult.EqualConstraintResult().

bool NUnit.Framework.Constraints.EqualConstraint.CaseInsensitive
get

Gets a value indicating whether to compare case insensitive.

true if comparing case insensitive; otherwise, false.

Referenced by NUnit.Framework.Constraints.EqualConstraintResult.EqualConstraintResult().

bool NUnit.Framework.Constraints.EqualConstraint.ClipStrings
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().

IList<NUnitEqualityComparer.FailurePoint> NUnit.Framework.Constraints.EqualConstraint.FailurePoints
get

Gets the failure points.

The failure points.

Referenced by NUnit.Framework.Constraints.EqualConstraintResult.EqualConstraintResult().

EqualConstraint NUnit.Framework.Constraints.EqualConstraint.IgnoreCase
get
EqualConstraint NUnit.Framework.Constraints.EqualConstraint.AsCollection
get

Flag the constraint to compare arrays as collections and return self.

EqualConstraint NUnit.Framework.Constraints.EqualConstraint.WithSameOffset
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.

EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Ulps
get

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

Returns
Self.

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().

EqualConstraint NUnit.Framework.Constraints.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.

Returns
Self

Referenced by NUnit.Framework.Constraints.EqualConstraintTests.FloatingPointEquality.ErrorWithPercentAndUlpsToleranceModes(), and NUnit.Framework.Constraints.EqualConstraintTests.FloatingPointEquality.ErrorWithUlpsAndPercentToleranceModes().

EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Days
get

Causes the tolerance to be interpreted as a TimeSpan in days.

Returns
Self
EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Hours
get

Causes the tolerance to be interpreted as a TimeSpan in hours.

Returns
Self
EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Minutes
get

Causes the tolerance to be interpreted as a TimeSpan in minutes.

Returns
Self
EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Seconds
get

Causes the tolerance to be interpreted as a TimeSpan in seconds.

Returns
Self
EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Milliseconds
get

Causes the tolerance to be interpreted as a TimeSpan in milliseconds.

Returns
Self
EqualConstraint NUnit.Framework.Constraints.EqualConstraint.Ticks
get
override string NUnit.Framework.Constraints.EqualConstraint.Description
get

The Description of what this constraint tests, for use in messages and in the ConstraintResult.


The documentation for this class was generated from the following file: