public void Execute_LargeVolumeCandidate_Fast(int maxItem) { var reference = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 1, 2, 3 }); var candidate = new DataTable(); var idColumn = candidate.Columns.Add("id"); var valueColumn = candidate.Columns.Add("value"); var randomizer = new Random(); for (int i = 0; i < maxItem; i++) { var dr = candidate.NewRow(); dr.SetField <object>(idColumn, i); dr.SetField <object>(valueColumn, randomizer.Next().ToString()); candidate.Rows.Add(dr); } candidate.AcceptChanges(); var mappingKey = new ColumnMappingCollection { new ColumnMapping(new ColumnNameIdentifier("id"), new ColumnNameIdentifier("two"), ColumnType.Numeric) }; var mappingValue = new ColumnMappingCollection { new ColumnMapping(new ColumnNameIdentifier("value"), new ColumnNameIdentifier("one"), ColumnType.Text) }; var analyzer = new LookupMatchesAnalyzer(mappingKey, mappingValue); var stopWatch = new Stopwatch(); stopWatch.Start(); var violations = analyzer.Execute(candidate, reference); stopWatch.Stop(); Assert.That(stopWatch.Elapsed.TotalSeconds, Is.LessThan(7)); }
public void Execute_MissingKeyInReference_OneViolation() { var candidate = BuildDataTable(new[] { "Key0", "Key1" }, new object[] { 0, 1 }); var reference = BuildDataTable(new[] { "Key0", "Key2", "Key2", "Key0", "Key2" }, new object[] { 0, 1, 1, 1, 1 }); var analyzer = new LookupMatchesAnalyzer(BuildColumnMapping(1), BuildColumnMapping(1, 1)); var violations = analyzer.Execute(candidate, reference); Assert.That(violations.Count(), Is.EqualTo(1)); }
public void Execute_ReferenceLargerThanCandidateDuplicateKeys_NoViolation() { var candidate = BuildDataTable(new[] { "Key0", "Key1" }, new object[] { 0, 1 }); var reference = BuildDataTable(new[] { "Key0", "Key1", "Key2", "Key1", "Key2" }, new object[] { 0, 2, 3, 1, 3 }); var analyzer = new LookupMatchesAnalyzer(BuildColumnMapping(1), BuildColumnMapping(1, 1)); var violations = analyzer.Execute(candidate, reference); Assert.That(violations.Count(), Is.EqualTo(0)); }
public void Execute_ReferenceLargerThanCandidateMatchingValueWhenNoToleranceApplied_OneViolation() { var candidate = BuildDataTable(new[] { "Key0", "Key1" }, new object[] { 0, 1 }); var reference = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new object[] { 0, 2, 1 }); var analyzer = new LookupMatchesAnalyzer(BuildColumnMapping(1), BuildColumnMapping(1, 1, ColumnType.Numeric)); var violations = analyzer.Execute(candidate, reference); Assert.That(violations.Count(), Is.EqualTo(1)); }
public void Execute_ReferenceLargerThanCandidateMatchingValueWhenToleranceApplied_NoViolation() { var candidate = BuildDataTable(new[] { "Key0", "Key1" }, new object[] { 0, 1 }); var reference = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new object[] { 0, 2, 1 }); var tolerances = new Dictionary <IColumnIdentifier, Tolerance>() { { new ColumnIdentifierFactory().Instantiate("#1"), new NumericAbsoluteTolerance(1, SideTolerance.Both) } }; var analyzer = new LookupMatchesAnalyzer(BuildColumnMapping(1), BuildColumnMapping(1, 1, ColumnType.Numeric), tolerances); var violations = analyzer.Execute(candidate, reference); Assert.That(violations.Count(), Is.EqualTo(0)); }