private MarkdownContainer BuildTable(TableHelper tableBuilder, IEnumerable <DataRow> rows, string title, ISampler <DataRow> sampler) { rows = rows ?? new List <DataRow>(); sampler.Build(rows); var table = tableBuilder.Build(sampler.GetResult()); var container = new MarkdownContainer(); if (!String.IsNullOrEmpty(title)) { var titleText = string.Format($"{title} rows:"); container.Append(titleText.ToMarkdownSubHeader()); } container.Append(BuildRowCount(rows.Count())); container.Append(table); if (sampler.GetIsSampled()) { var rowsSkipped = string.Format($"{sampler.GetExcludedRowCount()} (of {rows.Count()}) rows have been skipped for display purpose."); container.Append(rowsSkipped.ToMarkdownParagraph()); } return(container); }
private MarkdownContainer BuildTable(TableHelper tableBuilder, IEnumerable <DataRow> rows, string title, FailureReportSetType sampling) { rows = rows ?? new List <DataRow>(); var table = tableBuilder.Build(Sample(rows, sampling)); var container = new MarkdownContainer(); if (!String.IsNullOrEmpty(title)) { var titleText = string.Format("{0} rows:", title); container.Append(titleText.ToMarkdownSubHeader()); } container.Append(BuildRowCount(rows.Count())); container.Append(table); if (IsSampled(rows, sampling)) { var rowsSkipped = string.Format("{0} (of {1}) rows have been skipped for display purpose.", CountExcludedRows(rows), rows.Count()); container.Append(rowsSkipped.ToMarkdownParagraph()); } return(container); }
private MarkdownContainer BuildMultipleTable(ReferenceViolations violations, string title, ISampler <KeyCollection> keyCollectionSampler, ISampler <DataRow> dataRowSampler) { var tableBuilder = new TableHelper(EngineStyle.ByIndex); var container = new MarkdownContainer(); keyCollectionSampler.Build(violations.Keys); container.Append($"{violations.Keys.Count} missing reference{(violations.Keys.Count>1 ? "s" : string.Empty)}".ToMarkdownHeader()); if (keyCollectionSampler.GetIsSampled()) { container.Append($"{keyCollectionSampler.GetExcludedRowCount()} (of {violations.Keys.Count}) rows have been skipped for display purpose.".ToMarkdownParagraph()); } foreach (var keyCollection in keyCollectionSampler.GetResult()) { var rows = violations[keyCollection]; container.Append($"Following reference is missing ({rows.Count} occurence{(rows.Count > 1 ? "s" : string.Empty)}):".ToMarkdownParagraph()); container.Append(new BulletedList(keyCollection.Members.Cast <string>())); dataRowSampler.Build(rows); var table = tableBuilder.Build(dataRowSampler.GetResult()); container.Append(BuildRowCount(rows.Count())); container.Append(table); if (dataRowSampler.GetIsSampled()) { var rowsSkipped = $"{dataRowSampler.GetExcludedRowCount()} (of {rows.Count()}) rows have been skipped for display purpose."; container.Append(rowsSkipped.ToMarkdownParagraph()); } } return(container); }
public void BuildDuplication(IEnumerable <DataRow> actualRows, DuplicatedRowsResult result) { actual = new MarkdownContainer(); actual.Append(new Paragraph($"The actual result-set has {result.RowCount} rows and contains {result.Values.Count()} unique rows duplicated.")); actual.Append(BuildTable(style, actualRows, Profile.ActualSet)); duplicated = new MarkdownContainer(); duplicated.Append(BuildNonEmptyTable(style, result.Rows, "Duplicated", Profile.AnalysisSet)); }
private MarkdownContainer BuildList(IEnumerable <string> items, string title, FailureReportSetType sampling) { var container = new MarkdownContainer(); container.Append((title + " items:").ToMarkdownSubHeader()); container.Append(BuildList(items, sampling)); return(container); }
private MarkdownContainer BuildList(IEnumerable <string> items, string title, ISampler <string> sampler) { var container = new MarkdownContainer(); container.Append((title + " items:").ToMarkdownSubHeader()); container.Append(BuildList(items, sampler)); return(container); }
public void BuildComparaison(IEnumerable <DataRow> expectedRows, IEnumerable <DataRow> actualRows, ResultResultSet compareResult) { compareResult = compareResult ?? ResultResultSet.Build(new List <DataRow>(), new List <DataRow>(), new List <DataRow>(), new List <DataRow>(), new List <DataRow>()); expected = BuildTable(style, expectedRows, samplers["expected"]); actual = BuildTable(style, actualRows, samplers["actual"]); analysis = BuildNonEmptyTable(style, compareResult.Unexpected, "Unexpected", samplers["analysis"]); analysis.Append(BuildNonEmptyTable(style, compareResult.Missing ?? new List <DataRow>(), "Missing", samplers["analysis"])); analysis.Append(BuildNonEmptyTable(style, compareResult.Duplicated ?? new List <DataRow>(), "Duplicated", samplers["analysis"])); analysis.Append(BuildCompareTable(style, compareResult.NonMatchingValue.Rows ?? new List <DataRow>(), "Non matching value", samplers["analysis"])); }
public override void Render(MarkdownContainer container) { if (Rows.Count() == 0) { RenderEmptyTable(container); } else { RenderNonEmptyTable(Rows, Metadatas, Sampler, container); } }
public void Build(IEnumerable <string> expectedItems, IEnumerable <string> actualItems, ListComparer.Result result) { expectedItems = expectedItems ?? new List <string>(); actualItems = actualItems ?? new List <string>(); result = result ?? new ListComparer.Result(null, null); expected = BuildList(expectedItems, samplers["expected"]); actual = BuildList(actualItems, samplers["actual"]); analysis = BuildIfNotEmptyList(result.Missing ?? new List <string>(), "Missing", samplers["analysis"]); analysis.Append(BuildIfNotEmptyList(result.Unexpected ?? new List <string>(), "Unexpected", samplers["analysis"])); }
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 BuildDuplication(IEnumerable <DataRow> actualRows, ResultUniqueRows result) { actual = new MarkdownContainer(); var sb = new StringBuilder(); var uniqueCount = actualRows.Count() - result.Rows.Sum(x => Convert.ToInt32(x[0])); sb.Append($"The actual result-set has {result.RowCount} rows."); sb.Append($" {uniqueCount} row{(uniqueCount > 1 ? "s are" : " is")} effectively unique"); sb.Append($" and {result.Values.Count()} distinct row{(result.Values.Count() > 1 ? "s are" : " is")} duplicated."); actual.Append(new Paragraph(sb.ToString())); actual.Append(BuildTable(style, actualRows, samplers["actual"])); analysis = new MarkdownContainer(); analysis.Append(BuildNonEmptyTable(style, result.Rows, "Duplicated", samplers["analysis"])); }
public MarkdownContainer Build(IEnumerable <DataRow> dataRows) { var container = new MarkdownContainer(); if (dataRows.Count() == 0) { container.Append(BuildEmptyTable()); } else { container.Append(BuildNonEmptyTable(dataRows)); } return(container); }
public void ContainerExample() { var log = new MarkdownContainer(); var countries = new[] { "Zimbabwe", "Italy", "Bolivia", "Finland", "Australia" }; log.Append("Countries (unsorted)".ToMarkdownHeader()); log.Append(countries.ToMarkdownNumberedList()); var sorted = countries.OrderBy(i => i); log.Append("Countries (sorted)".ToMarkdownHeader()); log.Append(sorted.ToMarkdownNumberedList()); Console.Write(log); }
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('|')); }
private MarkdownContainer BuildList(IEnumerable <string> items, FailureReportSetType sampling) { var sampledItems = Sample(items, sampling).ToList(); var container = new MarkdownContainer(); if (items.Count() > 0) { container.Append(string.Format("Set of {0} item{1}", items.Count(), items.Count() > 1 ? "s" : string.Empty).ToMarkdownParagraph()); container.Append(sampledItems.ToMarkdownBulletedList()); } else { container.Append("An empty set.".ToMarkdownParagraph()); } if (IsSampled(items, sampling)) { container.Append(string.Format("... and {0} others not displayed.", CountExcludedRows(items)).ToMarkdownParagraph()); } return(container); }
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")); }
private MarkdownContainer BuildList(IEnumerable <string> items, ISampler <string> sampler) { sampler.Build(items); var sampledItems = sampler.GetResult(); var container = new MarkdownContainer(); if (items.Count() > 0) { container.Append($"Set of {items.Count()} item{(items.Count() > 1 ? "s" : string.Empty)}".ToMarkdownParagraph()); container.Append(sampledItems.ToMarkdownBulletedList()); } else { container.Append("An empty set.".ToMarkdownParagraph()); } if (sampler.GetIsSampled()) { container.Append($"... and {sampler.GetExcludedRowCount()} others not displayed.".ToMarkdownParagraph()); } return(container); }
public void TestCanConfigureOutputOfCollectionsUsingExtensionMethod() { var bart = new Person { Name = "Bart Simpson", Age = 10 }; var lisa = new Person { Name = "Lisa Simpson", Age = 8 }; var maggie = new Person { Name = "Maggie Simpson", Age = 1 }; var homer = new Person { Name = "Homer Simpson", Age = 36, Children = new[] { bart, lisa, maggie } }; var marge = new Person { Name = "Marge Simpson", Age = 35, Children = new[] { bart, lisa, maggie } }; var milhouse = new Person { Name = "Milhouse Van Houten ", Age = 10 }; var simpsons = new[] { homer, marge, bart, lisa, maggie, milhouse }; var md = new MarkdownContainer(); md.Append("Table built with no options".ToMarkdownHeader()); md.Append(simpsons.ToMarkdownTable()); md.Append("Table built with Default options".ToMarkdownHeader()); md.Append(simpsons.ToMarkdownTable(TableOptions.Default)); md.Append("Table built with ExcludeCollectionProperties options".ToMarkdownHeader()); md.Append(simpsons.ToMarkdownTable(TableOptions.ExcludeCollectionProperties)); Console.WriteLine(md); }
public void BuildCount(IEnumerable <DataRow> actualRows) { actual = BuildTable(style, actualRows, samplers["actual"]); }
protected virtual void RenderEmptyTable(MarkdownContainer container) => container.Append("This result-set is empty.".ToMarkdownParagraph());
protected override void RenderAnalysis(LookupViolationCollection violations, IEnumerable <ColumnMetadata> metadata, ISampler <DataRow> sampler, ColumnMappingCollection keyMappings, ColumnMappingCollection valueMappings, MarkdownContainer container) { container.Append("Analysis".ToMarkdownHeader()); var state = violations.Values.Select(x => x.State).First(); container.Append(GetExplanationText(violations, state).ToMarkdownParagraph()); var rows = violations.Values.Where(x => x is LookupExistsViolationInformation) .Cast <LookupExistsViolationInformation>() .SelectMany(x => x.CandidateRows); sampler.Build(rows); var tableHelper = new StandardTableHelperMarkdown(rows, metadata, sampler); tableHelper.Render(container); }
public TestSceneMarkdown() { MarkdownContainer markdownContainer; Add(markdownContainer = new MarkdownContainer { RelativeSizeAxes = Axes.Both, }); AddStep("Markdown Heading", () => { markdownContainer.Text = @"# Header 1 ## Header 2 ### Header 3 #### Header 4 ##### Header 5"; }); AddStep("Markdown Seperator", () => { markdownContainer.Text = @"Line above --- Line below"; }); AddStep("Markdown Heading", () => { markdownContainer.Text = @"- [1. Blocks](#1-blocks) - [1.1 Code block](#11-code-block) - [1.2 Text block](#12-text-block) - [1.3 Escape block](#13-escape-block) - [1.4 Whitespace control](#14-whitespace-control) - [2 Comments](#2-comments) - [3 Literals](#3-literals) - [3.1 Strings](#31-strings) - [3.2 Numbers](#32-numbers) - [3.3 Boolean](#33-boolean) - [3.4 null](#34-null)"; }); AddStep("Markdown Quote", () => { markdownContainer.Text = @"> **input**"; }); AddStep("Markdown Fenced Code", () => { markdownContainer.Text = @"```scriban-html [Escape me] [[Escape me]] {{ x = ""5"" # This assignment will not output anything x # This expression will print 5 x + 1 # This expression will print 6 }} ```"; }); AddStep("Markdown Table", () => { markdownContainer.Text = @"|Operator | Description |--------------------|------------ | `'left' + <right>` | concatenates left to right string: `""ab"" + ""c"" -> ""abc""` | `'left' * <right>` | concatenates the left string `right` times: `'a' * 5 -> aaaaa`. left and right and be swapped as long as there is one string and one number."; }); AddStep("Markdown Table (Aligned)", () => { markdownContainer.Text = @"| Left-Aligned | Center Aligned | Right Aligned | | :------------ |:---------------:| -----:| | col 3 is | some wordy text | $1600 | | col 2 is | centered | $12 | | zebra stripes | are neat | $1 |"; }); AddStep("Markdown Paragraph 1", () => { markdownContainer.Text = @"A text enclosed by `{{` and `}}` is a scriban **code block** that will be evaluated by the scriban templating engine."; }); AddStep("Markdown Paragraph 2", () => { markdownContainer.Text = @"The greedy mode using the character - (e.g {{- or -}}), removes any whitespace, including newlines Examples with the variable name = ""foo"":"; }); AddStep("MarkdownLink", () => { markdownContainer.Text = @"[click the circles to the beat](https://osu.ppy.sh)"; }); AddStep("MarkdownImage", () => { markdownContainer.Text = @"![peppy!](https://a.ppy.sh/2)"; }); AddStep("MarkdownFromInternet", () => { var req = new WebRequest("https://raw.githubusercontent.com/ppy/osu-wiki/master/wiki/Skinning/skin.ini/en.md"); req.Finished += () => markdownContainer.Text = req.ResponseString; Task.Run(() => req.PerformAsync()); }); AddStep("Emphases", () => { markdownContainer.Text = @"_italic with underscore_ *italic with asterisk* __bold with underscore__ **bold with asterisk** *__italic with asterisk, bold with underscore__* _**italic with underscore, bold with asterisk**_"; }); AddStep("new lines", () => { markdownContainer.Text = @"line 1 soft break\ soft break with '\'"; }); }
protected virtual void RenderNonEmptyTable(IEnumerable <T> rows, IEnumerable <ColumnMetadata> metadatas, ISampler <T> sampler, MarkdownContainer container) { var extendedDefinitions = BuildExtendedMetadatas(rows.ElementAt(0), metadatas); container.Append($"Result-set with {rows.Count()} row{(rows.Count() > 1 ? "s" : string.Empty)}".ToMarkdownParagraph()); container.Append(new TableExtended() { Columns = RenderColumns(extendedDefinitions), Rows = RenderRows(Sampler.GetResult(), extendedDefinitions) }); if (Sampler.GetIsSampled()) { var rowsSkipped = $"{Sampler.GetExcludedRowCount()} (of {Rows.Count()}) rows have been skipped for display purpose."; container.Append(rowsSkipped.ToMarkdownParagraph()); } }
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 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 Generate(IEnumerable <DataRow> parentRows, IEnumerable <DataRow> childRows, ReferenceViolations violations) { parent = BuildTable(parentRows, dataRowsSamplers["expected"]); child = BuildTable(childRows, dataRowsSamplers["actual"]); analysis = BuildMultipleTable(violations, "Missing references", keysCollectionSamplers["analysis"], dataRowsSamplers["analysis"]); }
public void BuildFilter(IEnumerable <DataRow> actualRows, IEnumerable <DataRow> filteredRows) { actual = BuildTable(style, actualRows, samplers["actual"]); analysis = BuildTable(style, filteredRows, samplers["actual"]); }