Esempio n. 1
0
 public string RenderActual()
 {
     if (samplers["actual"] is NoneSampler <DataRow> )
     {
         return("Display skipped.");
     }
     else
     {
         return(actual.ToMarkdown());
     }
 }
Esempio n. 2
0
 public string RenderAnalysis()
 {
     if (samplers["analysis"] is NoneSampler <DataRow> )
     {
         return("Display skipped.");
     }
     else
     {
         return(analysis.ToMarkdown());
     }
 }
Esempio n. 3
0
 public string RenderExpected()
 {
     if (samplers["expected"] is NoneSampler <DataRow> )
     {
         return("Display skipped.");
     }
     else
     {
         return(expected.ToMarkdown());
     }
 }
Esempio n. 4
0
        public void Render_OneViolationWithOneRecordOfTwoWrongFields_Correct()
        {
            var candidateTable = new DataTable()
            {
                TableName = "MyTable"
            };

            candidateTable.Columns.Add(new DataColumn("Id"));
            candidateTable.Columns.Add(new DataColumn("ForeignKey"));
            candidateTable.Columns.Add(new DataColumn("Numeric value"));
            candidateTable.Columns.Add(new DataColumn("Boolean value"));
            candidateTable.LoadDataRow(new object[] { 1, "Alpha", 10, true }, false);
            candidateTable.LoadDataRow(new object[] { 2, "Beta", 20, false }, false);

            var foreignKeyDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("ForeignKey"), Role = ColumnRole.Key
            };
            var numericDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("Numeric value"), Role = ColumnRole.Value
            };
            var booleanDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("Boolean value"), Role = ColumnRole.Value
            };

            var records = new List <LookupMatchesViolationRecord>()
            {
                new LookupMatchesViolationRecord()
                {
                    { candidateTable.Columns[2], new LookupMatchesViolationData(false, 15) },
                    { candidateTable.Columns[3], new LookupMatchesViolationData(false, false) },
                },
            };
            var association = new LookupMatchesViolationComposite(candidateTable.Rows[0], records);

            var sampler = new FullSampler <LookupMatchesViolationComposite>();

            sampler.Build(new[] { association });
            var msg = new LookupTableHelperMarkdown(new[] { association }
                                                    , new[] { foreignKeyDefinition, numericDefinition, booleanDefinition }
                                                    , sampler);
            var container = new MarkdownContainer();

            msg.Render(container);
            var value = container.ToMarkdown();

            Console.WriteLine(value);
            Assert.That(value.Count(c => c == '\n'), Is.EqualTo(6));
            Assert.That(value, Does.Contain("| 10 <> 15"));
            Assert.That(value, Does.Contain("| True <> False"));
        }
Esempio n. 5
0
        public void Build_TwoRowsByOrdinal_FirstRow()
        {
            var dataTable = new DataTable()
            {
                TableName = "MyTable"
            };

            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            dataTable.LoadDataRow(new object[] { "Alpha", 10, true }, false);
            dataTable.LoadDataRow(new object[] { "Beta", 20, false }, false);

            var idDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("#0"), Role = ColumnRole.Key
            };
            var numericDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("#1"), Role = ColumnRole.Value
            };
            var booleanDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("#2"), Role = ColumnRole.Value
            };

            var sampler = new FullSampler <DataRow>();

            sampler.Build(dataTable.Rows.Cast <DataRow>());
            var msg = new StandardTableHelperMarkdown(dataTable.Rows.Cast <DataRow>()
                                                      , new ColumnMetadata[] { idDefinition, numericDefinition, booleanDefinition }
                                                      , sampler);
            var container = new MarkdownContainer();

            msg.Render(container);
            var value = container.ToMarkdown();

            Assert.That(value.Count(c => c == '\n'), Is.EqualTo(7));

            var indexes = value.IndexOfAll('\n').ToArray();

            var titleLine = value.Substring(indexes[1] + 1, indexes[2] - indexes[1] - 2);

            Assert.That(titleLine.Replace(" ", ""), Is.EqualTo("#0(Id)|#1(Numericvalue)|#2(Booleanvalue)"));
        }
Esempio n. 6
0
        public void Build_TwoRows_ColumnDelimitersAlligned()
        {
            var dataTable = new DataTable()
            {
                TableName = "MyTable"
            };

            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            dataTable.LoadDataRow(new object[] { "Alpha", 10, true }, false);
            dataTable.LoadDataRow(new object[] { "Beta", 20, false }, false);

            var idDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("#0"), Role = ColumnRole.Key
            };

            var sampler = new FullSampler <DataRow>();

            sampler.Build(dataTable.Rows.Cast <DataRow>());
            var msg = new StandardTableHelperMarkdown(dataTable.Rows.Cast <DataRow>()
                                                      , new ColumnMetadata[] { idDefinition }
                                                      , sampler);
            var container = new MarkdownContainer();

            msg.Render(container);
            var value = container.ToMarkdown();
            var lines = value.Replace("\n", string.Empty).Split('\r');

            int pos = 0;

            while ((pos = lines[0].IndexOf('|', pos + 1)) > 0)
            {
                foreach (var line in lines.TakeWhile(l => l.Length > 0))
                {
                    Assert.That(line[pos], Is.EqualTo('|'), "The line '{0}' was expecting to have a '|' at position {1} but it was a '{2}'", new object[] { line, pos, line[pos] });
                }
            }
        }
Esempio n. 7
0
        public void Build_TwoRows_SevenLines()
        {
            var dataTable = new DataTable()
            {
                TableName = "MyTable"
            };

            dataTable.Columns.Add(new DataColumn("Id"));
            dataTable.Columns.Add(new DataColumn("Numeric value"));
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            dataTable.LoadDataRow(new object[] { "Alpha", 10, true }, false);
            dataTable.LoadDataRow(new object[] { "Beta", 20, false }, false);

            var idDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("Id"), Role = ColumnRole.Key
            };

            var sampler = new FullSampler <DataRow>();

            sampler.Build(dataTable.Rows.Cast <DataRow>());
            var msg = new StandardTableHelperMarkdown(dataTable.Rows.Cast <DataRow>()
                                                      , new ColumnMetadata[] { idDefinition }
                                                      , sampler);
            var container = new MarkdownContainer();

            msg.Render(container);
            var value = container.ToMarkdown();

            Assert.That(value.Count(c => c == '\n'), Is.EqualTo(7));

            var indexes  = value.IndexOfAll('\n').ToArray();
            var dashLine = value.Substring(indexes[3] + 1, indexes[4] - indexes[3] - 2);

            Assert.That(dashLine.Distinct().Count(), Is.EqualTo(3));
            Assert.That(dashLine.Distinct(), Has.Member(' '));
            Assert.That(dashLine.Distinct(), Has.Member('-'));
            Assert.That(dashLine.Distinct(), Has.Member('|'));
        }
Esempio n. 8
0
        public void Build_TwoRows_NumericValuesNonRounded()
        {
            var dataTable = new DataTable()
            {
                TableName = "MyTable"
            };

            dataTable.Columns.Add(new DataColumn("Id"));
            var numericDataColumn = new DataColumn("Numeric value");

            numericDataColumn.ExtendedProperties.Add("NBi::Type", ColumnType.Numeric);
            dataTable.Columns.Add(numericDataColumn);
            dataTable.Columns.Add(new DataColumn("Boolean value"));
            dataTable.LoadDataRow(new object[] { "Alpha", 10.752, true }, false);
            dataTable.LoadDataRow(new object[] { "Beta", 20.8445585, false }, false);

            var numericDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("Numeric value"), Role = ColumnRole.Value, Type = ColumnType.Numeric
            };

            var sampler = new FullSampler <DataRow>();

            sampler.Build(dataTable.Rows.Cast <DataRow>());
            var msg = new StandardTableHelperMarkdown(dataTable.Rows.Cast <DataRow>()
                                                      , new ColumnMetadata[] { numericDefinition }
                                                      , sampler);
            var container = new MarkdownContainer();

            msg.Render(container);
            var value = container.ToMarkdown();
            var lines = value.Replace("\n", string.Empty).Split('\r');

            Assert.That(value, Is.StringContaining("10.752 "));
            Assert.That(value, Is.StringContaining("20.8445585"));
        }
Esempio n. 9
0
 public virtual string RenderExpected() => keysCollectionSamplers["expected"] is NoneSampler <KeyCollection>?  "Display skipped." : parent.ToMarkdown();
Esempio n. 10
0
 public virtual string RenderActual()
 {
     return(actual.ToMarkdown());
 }
Esempio n. 11
0
        public void Render_TwoViolationsForSameKey_Correct()
        {
            var candidateTable = new DataTable()
            {
                TableName = "MyTable"
            };

            candidateTable.Columns.Add(new DataColumn("Id"));
            candidateTable.Columns.Add(new DataColumn("ForeignKey"));
            candidateTable.Columns.Add(new DataColumn("Numeric value"));
            candidateTable.Columns.Add(new DataColumn("Boolean value"));
            candidateTable.LoadDataRow(new object[] { 1, "Alpha", 10, true }, false);
            candidateTable.LoadDataRow(new object[] { 2, "Alpha", 20, false }, false);

            var foreignKeyDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("ForeignKey"), Role = ColumnRole.Key
            };
            var numericDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("Numeric value"), Role = ColumnRole.Value, Type = ColumnType.Numeric
            };
            var booleanDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("Boolean value"), Role = ColumnRole.Value, Type = ColumnType.Boolean
            };

            var records = new List <LookupMatchesViolationRecord>()
            {
                new LookupMatchesViolationRecord()
                {
                    { candidateTable.Columns[2], new LookupMatchesViolationData(false, "17.0") },
                    { candidateTable.Columns[3], new LookupMatchesViolationData(false, false) },
                },
                new LookupMatchesViolationRecord()
                {
                    { candidateTable.Columns[2], new LookupMatchesViolationData(false, "12") },
                    { candidateTable.Columns[3], new LookupMatchesViolationData(false, false) },
                },
                new LookupMatchesViolationRecord()
                {
                    { candidateTable.Columns[2], new LookupMatchesViolationData(false, "18") },
                    { candidateTable.Columns[3], new LookupMatchesViolationData(true, true) },
                },
            };
            var firstAssociation  = new LookupMatchesViolationComposite(candidateTable.Rows[0], records);
            var secondAssociation = new LookupMatchesViolationComposite(candidateTable.Rows[1], records);

            var sampler = new FullSampler <LookupMatchesViolationComposite>();

            sampler.Build(new[] { firstAssociation, secondAssociation });
            var msg = new LookupTableHelperMarkdown(new[] { firstAssociation, secondAssociation }
                                                    , new[] { foreignKeyDefinition, numericDefinition, booleanDefinition }
                                                    , sampler);
            var container = new MarkdownContainer();

            msg.Render(container);
            var value = container.ToMarkdown();

            Console.WriteLine(value);
            Assert.That(value.Count(c => c == '\n'), Is.EqualTo(11));
            Assert.That(value, Does.Contain("Result-set with 2 rows"));
            Assert.That(value, Does.Contain("#0 (Id) | #1 (ForeignKey) | #2 (Numeric value) | #3 (Boolean value)"));
            Assert.That(value, Does.Contain("1       | Alpha           | 10 <> 17           | True <> False"));
            Assert.That(value, Does.Contain(">>      | >>              | 10 <> 12           | True <> False"));
            Assert.That(value, Does.Contain(">>      | >>              | 10 <> 18           | True"));
            Assert.That(value, Does.Contain("2       | Alpha           | 20 <> 17           | False <> False"));
            Assert.That(value, Does.Contain(">>      | >>              | 20 <> 12           | False <> False"));
            Assert.That(value, Does.Contain(">>      | >>              | 20 <> 18           | False"));
        }
Esempio n. 12
0
        public void Render_OneViolationWithOneRecordOfOneField_Correct()
        {
            var candidateTable = new DataTable()
            {
                TableName = "MyTable"
            };

            candidateTable.Columns.Add(new DataColumn("ForeignKey"));
            candidateTable.Columns.Add(new DataColumn("Numeric value"));
            candidateTable.Columns.Add(new DataColumn("Boolean value"));
            candidateTable.LoadDataRow(new object[] { "Alpha", 10, true }, false);
            candidateTable.LoadDataRow(new object[] { "Beta", 20, false }, false);

            var foreignKeyDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("ForeignKey"), Role = ColumnRole.Key
            };
            var numericDefinition = new ColumnMetadata()
            {
                Identifier = new ColumnIdentifierFactory().Instantiate("Numeric value"), Role = ColumnRole.Value
            };

            var keyMappings = new ColumnMappingCollection()
            {
                new ColumnMapping(foreignKeyDefinition.Identifier, ColumnType.Text)
            };
            var valueMappings = new ColumnMappingCollection()
            {
                new ColumnMapping(numericDefinition.Identifier, ColumnType.Numeric)
            };

            var records = new List <LookupMatchesViolationRecord>()
            {
                new LookupMatchesViolationRecord()
                {
                    { candidateTable.Columns[1], new LookupMatchesViolationData(false, 15) },
                },
            };
            var association = new LookupMatchesViolationComposite(candidateTable.Rows[0], records);

            var sampler = new FullSampler <LookupMatchesViolationComposite>();

            sampler.Build(new[] { association });
            var msg = new LookupTableHelperMarkdown(new[] { association }
                                                    , new[] { foreignKeyDefinition, numericDefinition }
                                                    , sampler);
            var container = new MarkdownContainer();

            msg.Render(container);
            var value = container.ToMarkdown();

            Console.WriteLine(value);

            Assert.That(value.Count(c => c == '\n'), Is.EqualTo(6));

            var indexes  = value.IndexOfAll('\n').ToArray();
            var dashLine = value.Substring(indexes[3] + 1, indexes[4] - indexes[3] - 2);

            Assert.That(dashLine.Distinct().Count(), Is.EqualTo(3));
            Assert.That(dashLine.Distinct(), Has.Member(' '));
            Assert.That(dashLine.Distinct(), Has.Member('-'));
            Assert.That(dashLine.Distinct(), Has.Member('|'));
        }
Esempio n. 13
0
 public virtual string RenderDuplicated()
 {
     return(duplicated.ToMarkdown());
 }
Esempio n. 14
0
 public virtual string RenderCompared()
 {
     return(compared.ToMarkdown());
 }
Esempio n. 15
0
 public virtual string RenderFiltered()
 {
     return(filtered.ToMarkdown());
 }
Esempio n. 16
0
 public virtual string RenderActual() => keysCollectionSamplers["actual"] is NoneSampler <KeyCollection>? "Display skipped." : child.ToMarkdown();
Esempio n. 17
0
 public virtual string RenderAnalysis() => keysCollectionSamplers["analysis"] is NoneSampler <KeyCollection>? "Display skipped." : analysis.ToMarkdown();
Esempio n. 18
0
 public virtual string RenderExpected()
 {
     return(expected.ToMarkdown());
 }