public void Execute_MissingItem_NoViolation() { var child = BuildDataTable(new[] { "Key0", "Key1" }, new object[] { 0, 1 }); var parent = BuildDataTable(new[] { "Key0", "Key2", "Key2", "Key0", "Key2" }, new object[] { 1, 1, 1, 1, 1 }); var referencer = new ReferenceAnalyzer(BuildColumnMapping(1)); var violations = referencer.Execute(child, parent); Assert.That(violations.Count(), Is.EqualTo(1)); }
public void Execute_MultipleKeysParentLargerThanChildDuplicateKeys_NoViolation() { var child = BuildDataTable(new[] { "Key0", "Key1" }, new[] { "Foo", "Bar" }, new object[] { 0, 1 }); var parent = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new[] { "Foo", "Bar", "Bar" }, new object[] { 1, 2, 3 }); var referencer = new ReferenceAnalyzer(BuildColumnMapping(2)); var violations = referencer.Execute(child, parent); Assert.That(violations.Count(), Is.EqualTo(0)); }
public void Execute_MultipleKeysPermuteValueColumnOneMissingParent_OneViolation() { var child = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new[] { "Foo", "Bar", "Bar" }, new object[] { 1, 2, 2 }); var parent = BuildDataTable(new[] { "Key0", "Key1" }, new[] { "Foo", "Bar" }, new object[] { 0, 1 }); parent.Columns[2].SetOrdinal(0); var referencer = new ReferenceAnalyzer(BuildColumnMapping(2, 1)); var violations = referencer.Execute(child, parent); Assert.That(violations.Count(), Is.EqualTo(1)); }
public void Execute_DuplicatedKeyColumnsOnBothSide_NoViolation() { var child = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 2 }); var parent = BuildDataTable(new[] { "Key0", "Key1", "Key1" }, new[] { "Foo", "Bar", "Bar" }, new object[] { 1, 2, 3 }); var mapping = new ColumnMappingCollection { new ColumnMapping("#0", "#0", ColumnType.Text), new ColumnMapping("#1", "#1", ColumnType.Text) }; var referencer = new ReferenceAnalyzer(mapping); var violations = referencer.Execute(child, parent); Assert.That(violations.Count(), Is.EqualTo(0)); }
public void Execute_NamedColumns_NoViolation() { var child = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 0 }); var parent = BuildDataTable(new[] { "Key0", "Key1", "Key1" }, new[] { "Foo", "Bar", "Bar" }, new[] { "0.000", "1.0", "2" }); var mapping = new ColumnMappingCollection { new ColumnMapping("zero", "zero", ColumnType.Text), new ColumnMapping("one", "one", ColumnType.Text), new ColumnMapping("two", "two", ColumnType.Numeric) }; var referencer = new ReferenceAnalyzer(mapping); var violations = referencer.Execute(child, parent); Assert.That(violations.Count(), Is.EqualTo(0)); }
public void Execute_MultipleKeysPermuteKeyColumnsOneMissingParent_OneViolation() { var child = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new[] { "Foo", "Bar", "Fie" }, new object[] { 1, 2, 3 }); var parent = BuildDataTable(new[] { "Key0", "Key1" }, new[] { "Foo", "Bar" }, new object[] { 0, 1 }); parent.Columns[1].SetOrdinal(0); var mapping = new ColumnMappingCollection { new ColumnMapping("#0", "#1", ColumnType.Text), new ColumnMapping("#1", "#0", ColumnType.Text) }; var referencer = new ReferenceAnalyzer(mapping); var violations = referencer.Execute(child, parent); Assert.That(violations.Count(), Is.EqualTo(1)); }