Table of Contents

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:

  • Two strings are compared as strings, not as parsed numbers: "100.2" is less than "2.5".
  • The string "100.2" is greater than the double 2.5.
  • The string "100.2" is equal to the double 100.2.
  • The int -3 is greater than the double -3.1.

Properties

Instance

Gets the singleton instance of ValidationComparer.

public static ValidationComparer Instance { get; }

Property Value

ValidationComparer

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

x object

The first object to compare.

y object

The second object to compare.

Returns

int

A signed integer that indicates the relative values of x and y:

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