public void TestOutput_RelativeTolerances(bool treatNullsAsZero, decimal relativeTolerance, decimal?expected, decimal?actual, decimal?difference) { var plugin = new DecimalComparerPlugin { RelativeTolerance = relativeTolerance, ToleranceModes = FloatingPointToleranceModes.RelativeTolerance, TreatMissingValuesAsZero = treatNullsAsZero }; this.PerformTest(plugin, expected, actual, difference); this.PerformTest(plugin, actual, expected, difference.HasValue ? (decimal?)(0 - difference.Value) : null); }
private void PerformTest(DecimalComparerPlugin plugin, decimal?expected, decimal?actual, decimal?difference) { var output = plugin.TryCompare("key", expected.HasValue ? (object)expected.Value : null, actual.HasValue ? (object)actual.Value : null); if (difference.HasValue) { Assert.Equal(ComparisonResultType.Different, output.ComparisonResultType); Assert.Equal(difference.Value, output.Payload); } else { Assert.Equal(ComparisonResultType.Equal, output.ComparisonResultType); } }