public void Compare_SameKeysSameValuesUselessColumnsNoneValuesMatching_ReturnEqual() { var settings = new SettingsIndexResultSet( SettingsIndexResultSet.KeysChoice.First, SettingsIndexResultSet.ValuesChoice.None, new List <IColumnDefinition>() { new Column() { Index = 1, Role = ColumnRole.Value, Type = ColumnType.Numeric } } ); //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), settings); var reference = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0, 1 }, new string[] { "Useless0", "Useless1" }); var actual = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0, 1 }, new string[] { "0Useless0", "0Useless1" }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.Matching)); }
public void Compare_SameRowsNumericKeys_ReturnEqual() { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValue(ColumnType.Numeric)); var reference = BuildDataTable(new string[] { "100", "12" }, new double[] { 0, 1 }); var actual = BuildDataTable(new string[] { "0100.00", "12.0" }, new double[] { 0, 1 }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.Matching)); }
public void Compare_DuplicatedRowInRef_ThrowException() { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValue()); var reference = BuildDataTable(new string[] { "Key0", "Key1", "Key1" }, new double[] { 0, 1, 2 }); var actual = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0, 1 }); //Assertion is generating an exception var ex = Assert.Throws <EquivalerException>(delegate { comparer.Compare(reference, actual); }); Assert.That(ex.Message, Is.StringContaining("<Key1|1>")); Assert.That(ex.Message, Is.StringContaining("<Key1|2>")); }
public void Compare_SameKeysDifferentValuesButWithinTolerance_ReturnEqual() { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValue(1)); var reference = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0, 1 }); var actual = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0.5, 1.5 }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.Matching)); }
public void Compare_DuplicatedRowButWithDifferentValue_ReturnNotEqual() { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValue()); var reference = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0, 1 }); var actual = BuildDataTable(new string[] { "Key0", "Key1", "Key2" }, new double[] { 0, 1, 2 }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.NotMatching)); }
public void Compare_DifferentRowsBooleanKeysWithBooleanType_ReturnNotEqual() { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValue(ColumnType.Boolean)); var reference = BuildDataTable(new string[] { "True" }, new double[] { 0, 1 }); var actual = BuildDataTableBoolean(new bool[] { false }, new double[] { 0, 1 }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.NotMatching)); }
public void Compare_DifferentRowsWithHoursNumericKeysWithDateTimeType_ReturnNotEqual() { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValue(ColumnType.DateTime)); var reference = BuildDataTable(new string[] { "2015-01-17", "2015-01-18" }, new double[] { 0, 1 }); var actual = BuildDataTableDateTime(new DateTime[] { new DateTime(2015, 01, 17), new DateTime(2015, 01, 18, 8, 0, 0) }, new double[] { 0, 1 }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.NotMatching)); }
public void Compare_DifferentRowsNumericKeysWithNumericType_ReturnNotEqual() { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValue(ColumnType.Numeric)); var reference = BuildDataTable(new string[] { "100", "12.750" }, new double[] { 0, 1 }); var actual = BuildDataTableNumeric(new decimal[] { new decimal(999), new decimal(12.75) }, new double[] { 0, 1 }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.NotMatching)); }
public void Compare_SameRowsDateTimeKeys_ReturnEqual() { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValue(ColumnType.DateTime)); var reference = BuildDataTable(new string[] { "2015-01-17", "2015-01-18" }, new double[] { 0, 1 }); var actual = BuildDataTable(new string[] { "17/01/2015", "18-01-2015" }, new double[] { 0, 1 }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.Matching)); }
public void Compare_ObjectsVersusSameTypedButWithPrecision_ReturnEqual() { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValue()); var reference = BuildDataTable(new object[] { "Key0", "Key1" }, new object[] { "0", "1.0" }); var actual = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0, 1 }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.Matching)); }
public void Compare_SameKeysSameValuesUselessColumnNotMatching_ReturnEqual() { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValueIgnore(0)); var reference = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0, 1 }, new string[] { "Useless0", "Useless1" }); var actual = BuildDataTable(new string[] { "Key0", "Key1" }, new double[] { 0, 1 }, new string[] { "0Useless0", "0Useless1" }); //Call the method to test var res = comparer.Compare(reference, actual); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.Matching)); }
//[TestCase(100, 1)] //[TestCase(1000, 1)] //[TestCase(10000, 1)] //[TestCase(100000, 10)] //[TestCase(1000000, 30)] public void Compare_DifferentLargeArrays_ReturnQuicklyDifferent(int count, int timeout) { //Buiding object used during test var comparer = new IndexEquivaler(AnalyzersFactory.EqualTo(), BuildSettingsKeyValue()); var reference = BuildDataTable(RandomLargeArrayString(count, 0), RandomLargeArrayDouble(count)); var actual = BuildDataTable(RandomLargeArrayString(count, Convert.ToInt32(count * 0.8)), RandomLargeArrayDouble(count)); Console.WriteLine("Starting comparaison for {0} rows", count); var stopWatch = new Stopwatch(); stopWatch.Start(); //Call the method to test var res = comparer.Compare(reference, actual); stopWatch.Stop(); Console.WriteLine("Compaired in {0} milliseconds", stopWatch.Elapsed.TotalMilliseconds); //Assertion Assert.That(res, Is.EqualTo(ResultResultSet.NotMatching)); Assert.That(stopWatch.Elapsed, Is.LessThan(new TimeSpan(0, 0, timeout))); }