示例#1
0
        public void Execute_MultipleKeysreferenceLargerThanCandidateDuplicateKeys_NoViolation()
        {
            var child     = BuildDataTable(new[] { "Key0", "Key1" }, new[] { "Foo", "Bar" }, new object[] { 0, 1 });
            var reference = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new[] { "Foo", "Bar", "Bar" }, new object[] { 1, 2, 3 });

            var referencer = new LookupExistsAnalyzer(BuildColumnMapping(2));
            var violations = referencer.Execute(child, reference);

            Assert.That(violations.Count(), Is.EqualTo(0));
        }
示例#2
0
        public void Execute_MissingItem_NoViolation()
        {
            var child     = BuildDataTable(new[] { "Key0", "Key1" }, new object[] { 0, 1 });
            var reference = BuildDataTable(new[] { "Key0", "Key2", "Key2", "Key0", "Key2" }, new object[] { 1, 1, 1, 1, 1 });

            var referencer = new LookupExistsAnalyzer(BuildColumnMapping(1));
            var violations = referencer.Execute(child, reference);

            Assert.That(violations.Count(), Is.EqualTo(1));
        }
示例#3
0
        public void Execute_MultipleKeysPermuteValueColumnOneMissingreference_OneViolation()
        {
            var child     = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new[] { "Foo", "Bar", "Bar" }, new object[] { 1, 2, 2 });
            var reference = BuildDataTable(new[] { "Key0", "Key1" }, new[] { "Foo", "Bar" }, new object[] { 0, 1 });

            reference.Columns[2].SetOrdinal(0);

            var referencer = new LookupExistsAnalyzer(BuildColumnMapping(2, 1));
            var violations = referencer.Execute(child, reference);

            Assert.That(violations.Count(), Is.EqualTo(1));
        }
示例#4
0
        public void Execute_DuplicatedKeyColumnsOnBothSide_NoViolation()
        {
            var child     = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 2 });
            var reference = BuildDataTable(new[] { "Key0", "Key1", "Key1" }, new[] { "Foo", "Bar", "Bar" }, new object[] { 1, 2, 3 });

            var mapping = new ColumnMappingCollection
            {
                new ColumnMapping(new ColumnOrdinalIdentifier(0), ColumnType.Text),
                new ColumnMapping(new ColumnOrdinalIdentifier(1), ColumnType.Text)
            };
            var referencer = new LookupExistsAnalyzer(mapping);
            var violations = referencer.Execute(child, reference);

            Assert.That(violations.Count(), Is.EqualTo(0));
        }
示例#5
0
        public void Execute_NamedColumns_NoViolation()
        {
            var child     = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 0 });
            var reference = BuildDataTable(new[] { "Key0", "Key1", "Key1" }, new[] { "Foo", "Bar", "Bar" }, new[] { "0.000", "1.0", "2" });

            var mapping = new ColumnMappingCollection
            {
                new ColumnMapping(new ColumnNameIdentifier("zero"), ColumnType.Text),
                new ColumnMapping(new ColumnNameIdentifier("one"), ColumnType.Text),
                new ColumnMapping(new ColumnNameIdentifier("two"), ColumnType.Numeric)
            };
            var referencer = new LookupExistsAnalyzer(mapping);
            var violations = referencer.Execute(child, reference);

            Assert.That(violations.Count(), Is.EqualTo(0));
        }
示例#6
0
        public void Execute_MultipleKeysPermuteKeyColumnsOneMissingreference_OneViolation()
        {
            var child     = BuildDataTable(new[] { "Key0", "Key1", "Key2" }, new[] { "Foo", "Bar", "Fie" }, new object[] { 1, 2, 3 });
            var reference = BuildDataTable(new[] { "Key0", "Key1" }, new[] { "Foo", "Bar" }, new object[] { 0, 1 });

            reference.Columns[1].SetOrdinal(0);

            var mapping = new ColumnMappingCollection
            {
                new ColumnMapping(new ColumnOrdinalIdentifier(0), new ColumnOrdinalIdentifier(1), ColumnType.Text),
                new ColumnMapping(new ColumnOrdinalIdentifier(1), new ColumnOrdinalIdentifier(0), ColumnType.Text)
            };
            var referencer = new LookupExistsAnalyzer(mapping);
            var violations = referencer.Execute(child, reference);

            Assert.That(violations.Count(), Is.EqualTo(1));
        }