public string RenderActual() { if (samplers["actual"] is NoneSampler <DataRow> ) { return("Display skipped."); } else { return(actual.ToMarkdown()); } }
public string RenderAnalysis() { if (samplers["analysis"] is NoneSampler <DataRow> ) { return("Display skipped."); } else { return(analysis.ToMarkdown()); } }
public string RenderExpected() { if (samplers["expected"] is NoneSampler <DataRow> ) { return("Display skipped."); } else { return(expected.ToMarkdown()); } }
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")); }
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)")); }
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] }); } } }
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('|')); }
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")); }
public virtual string RenderExpected() => keysCollectionSamplers["expected"] is NoneSampler <KeyCollection>? "Display skipped." : parent.ToMarkdown();
public virtual string RenderActual() { return(actual.ToMarkdown()); }
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")); }
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('|')); }
public virtual string RenderDuplicated() { return(duplicated.ToMarkdown()); }
public virtual string RenderCompared() { return(compared.ToMarkdown()); }
public virtual string RenderFiltered() { return(filtered.ToMarkdown()); }
public virtual string RenderActual() => keysCollectionSamplers["actual"] is NoneSampler <KeyCollection>? "Display skipped." : child.ToMarkdown();
public virtual string RenderAnalysis() => keysCollectionSamplers["analysis"] is NoneSampler <KeyCollection>? "Display skipped." : analysis.ToMarkdown();
public virtual string RenderExpected() { return(expected.ToMarkdown()); }