Class ValidationComparer
- Namespace
- Acuit.Pinpoint.Workflows.Testing.Validation
- Assembly
- Acuit.Pinpoint.Workflows.Testing.dll
A comparer that handles different but compatible numeric types.
public class ValidationComparer : IComparer<object>
- Inheritance
-
ValidationComparer
- Implements
- Inherited Members
Remarks
This is to support things like taking a reading (resulting in a TimestampedReadingValue), and being able to compare it to a value specified directly in a test workflow (e.g., as a double) to validate the reading.
Comparison rules are:
- null values are considered less than non-null values.
- If the objects are of the same type, their default comparison is performed.
- If the values are different types but can be converted to double values, then the resulting double values are compared.
NOTE: Comparisons completely ignore units on IDataValue objects.
For example:
Properties
Instance
Gets the singleton instance of ValidationComparer.
public static ValidationComparer Instance { get; }
Property Value
Methods
Compare(object, object)
Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
public int Compare(object x, object y)
Parameters
Returns
- int
A signed integer that indicates the relative values of
x
andy
:- Less than zero means <code class="paramref">x</code> is less than <code class="paramref">y</code>. - Zero means <code class="paramref">x</code> equals <code class="paramref">y</code>. - Greater than zero means <code class="paramref">x</code> is greater than <code class="paramref">y</code>.
Exceptions
- ArgumentException
At least one object must implement IComparable.
- ArgumentException
The comparison via one object's IComparable.CompareTo(object) failed.
- FormatException
A string object was not in a correct format to convert to a double.