Пример #1
0
        public void Execute_LargeVolumeChildAndReference_Fast(int maxItem)
        {
            var child   = new DataTable();
            var dtChild = child.Columns.Add("one");

            for (int i = 0; i < maxItem; i++)
            {
                var dr = child.NewRow();
                dr.SetField <object>(dtChild, i);
                child.Rows.Add(dr);
            }
            child.AcceptChanges();
            var reference = child.Copy();

            var mapping = new ColumnMappingCollection
            {
                new ColumnMapping(new ColumnNameIdentifier("one"), new ColumnNameIdentifier("one"), ColumnType.Numeric)
            };
            var referencer = new LookupExistsAnalyzer(mapping);
            var stopWatch  = new Stopwatch();

            stopWatch.Start();
            referencer.Execute(child, reference);
            stopWatch.Stop();
            Assert.That(stopWatch.Elapsed.TotalSeconds, Is.LessThan(10));
        }
Пример #2
0
        public void Execute_LargeVolumeChild_Fast(int maxItem)
        {
            var reference = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 1, 2, 3 });
            var child     = new DataTable();
            var dt        = child.Columns.Add("two");

            for (int i = 0; i < maxItem; i++)
            {
                var dr = child.NewRow();
                dr.SetField <object>(dt, i);
                child.Rows.Add(dr);
            }
            child.AcceptChanges();

            var mapping = new ColumnMappingCollection
            {
                new ColumnMapping(new ColumnNameIdentifier("two"), new ColumnNameIdentifier("two"), ColumnType.Numeric)
            };
            var referencer = new LookupExistsAnalyzer(mapping);
            var stopWatch  = new Stopwatch();

            stopWatch.Start();
            var violations = referencer.Execute(child, reference);

            stopWatch.Stop();
            Assert.That(stopWatch.Elapsed.TotalSeconds, Is.LessThan(10));
        }
Пример #3
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));
        }
Пример #4
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));
        }
Пример #5
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));
        }
Пример #6
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));
        }
Пример #7
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));
        }
Пример #8
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));
        }