How to use DataRowsMessageMarkdown method of NBi.Framework.FailureMessage.Markdown.DataRowsMessageMarkdown class

Best NBi code snippet using NBi.Framework.FailureMessage.Markdown.DataRowsMessageMarkdown.DataRowsMessageMarkdown

DataRowsMessageMardownTest.cs

Source:DataRowsMessageMardownTest.cs Github

copy

Full Screen

...38 dataTable.Columns.Add(new DataColumn("Boolean value"));39 for (int i = 0; i < 20; i++)40 dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);41 var samplers = new SamplersFactory<DataRow>().Instantiate(FailureReportProfile.Default);42 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);43 msg.BuildComparaison(dataTable.Rows.Cast<DataRow>(), null, null);44 var value = msg.RenderExpected();45 var lines = value.Replace("\n", string.Empty).Split('\r');46 Assert.That(lines[0], Is.EqualTo("Result-set with 20 rows"));47 }48 [Test]49 public void RenderExpected_OneRow_ReturnCorrectNumberOfRowsOnTopWithoutPlurial()50 {51 var dataTable = new DataTable() { TableName = "MyTable" };52 dataTable.Columns.Add(new DataColumn("Id"));53 dataTable.Columns.Add(new DataColumn("Numeric value"));54 dataTable.Columns.Add(new DataColumn("Boolean value"));55 for (int i = 0; i < 1; i++)56 dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);57 var samplers = new SamplersFactory<DataRow>().Instantiate(FailureReportProfile.Default);58 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);59 msg.BuildComparaison(dataTable.Rows.Cast<DataRow>(), null, null);60 var value = msg.RenderExpected();61 var lines = value.Replace("\n", string.Empty).Split('\r');62 Assert.That(lines[0], Is.EqualTo("Result-set with 1 row"));63 }64 [Test]65 public void RenderExpected_MoreThanMaxRowsCount_ReturnSampleRowsCountAndHeadersAndSeparation()66 {67 var dataSet = new DataSet();68 var dataTable = new DataTable() { TableName = "MyTable" };69 dataTable.Columns.Add(new DataColumn("Id"));70 dataTable.Columns.Add(new DataColumn("Numeric value"));71 dataTable.Columns.Add(new DataColumn("Boolean value"));72 dataTable.Columns["Id"].ExtendedProperties.Add("NBi::Role", ColumnRole.Key);73 for (int i = 0; i < 20; i++)74 dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);75 var samplers = new SamplersFactory<DataRow>().Instantiate(FailureReportProfile.Default);76 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);77 msg.BuildComparaison(dataTable.Rows.Cast<DataRow>(), null, null);78 var value = msg.RenderExpected();79 var lines = value.Replace("\n", string.Empty).Split('\r');80 Assert.That(lines.Count(l => l.Contains("|")), Is.EqualTo(10 + 3));81 }82 [Test]83 public void RenderExpected_MoreThanMaxRowsCount_ReturnSampleRowsCountAndHeaderAndSeparation()84 {85 var dataSet = new DataSet();86 var dataTable = new DataTable() { TableName = "MyTable" };87 dataTable.Columns.Add(new DataColumn("Id"));88 dataTable.Columns.Add(new DataColumn("Numeric value"));89 dataTable.Columns.Add(new DataColumn("Boolean value"));90 for (int i = 0; i < 20; i++)91 dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);92 var samplers = new SamplersFactory<DataRow>().Instantiate(FailureReportProfile.Default);93 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);94 msg.BuildComparaison(dataTable.Rows.Cast<DataRow>(), null, null);95 var value = msg.RenderExpected();96 var lines = value.Replace("\n", string.Empty).Split('\r');97 Assert.That(lines.Count(l => l.Contains("|")), Is.EqualTo(10 + 3 -1)); //-1 because we've no ExtendedProperties98 }99 [Test]100 public void RenderExpected_MoreThanSampleRowsCountButLessThanMaxRowsCount_ReturnEachRowAndHeaderAndSeparation()101 {102 var rowCount = 12;103 var dataSet = new DataSet();104 var dataTable = new DataTable() { TableName = "MyTable" };105 dataTable.Columns.Add(new DataColumn("Id"));106 dataTable.Columns.Add(new DataColumn("Numeric value"));107 dataTable.Columns.Add(new DataColumn("Boolean value"));108 dataTable.Columns["Id"].ExtendedProperties.Add("NBi::Role", ColumnRole.Key);109 for (int i = 0; i < rowCount; i++)110 dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);111 var samplers = new SamplersFactory<DataRow>().Instantiate(FailureReportProfile.Default);112 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);113 msg.BuildComparaison(dataTable.Rows.Cast<DataRow>(), null, null);114 var value = msg.RenderExpected();115 var lines = value.Replace("\n", string.Empty).Split('\r');116 117 Assert.That(lines.Count(l => l.Contains("|")), Is.EqualTo(rowCount + 3));118 }119 [Test]120 public void RenderExpected_MoreThanSampleRowsCountButLessThanMaxRowsCountWithSpecificProfile_ReturnEachRowAndHeaderAndSeparation()121 {122 var rowCount = 120;123 var threshold = rowCount - 20;124 var max = threshold / 2;125 var dataSet = new DataSet();126 var dataTable = new DataTable() { TableName = "MyTable" };127 dataTable.Columns.Add(new DataColumn("Id"));128 dataTable.Columns.Add(new DataColumn("Numeric value"));129 dataTable.Columns.Add(new DataColumn("Boolean value"));130 dataTable.Columns["Id"].ExtendedProperties.Add("NBi::Role", ColumnRole.Key);131 for (int i = 0; i < rowCount; i++)132 dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);133 var profile = Mock.Of<IFailureReportProfile>(p =>134 p.MaxSampleItem == max135 && p.ThresholdSampleItem == threshold136 && p.ExpectedSet == FailureReportSetType.Sample137 );138 var samplers = new SamplersFactory<DataRow>().Instantiate(profile);139 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);140 msg.BuildComparaison(dataTable.Rows.Cast<DataRow>(), null, null);141 var value = msg.RenderExpected();142 var lines = value.Replace("\n", string.Empty).Split('\r');143 144 Assert.That(lines.Count(l => l.Contains("|")), Is.EqualTo(max + 3));145 }146 [Test]147 public void RenderExpected_MoreThanSampleRowsCountButLessThanMaxRowsCountWithSpecificProfileFull_ReturnEachRowAndHeaderAndSeparation()148 {149 var rowCount = 120;150 var threshold = rowCount - 20;151 var max = threshold / 2;152 var dataSet = new DataSet();153 var dataTable = new DataTable() { TableName = "MyTable" };154 dataTable.Columns.Add(new DataColumn("Id"));155 dataTable.Columns.Add(new DataColumn("Numeric value"));156 dataTable.Columns.Add(new DataColumn("Boolean value"));157 dataTable.Columns["Id"].ExtendedProperties.Add("NBi::Role", ColumnRole.Key);158 for (int i = 0; i < rowCount; i++)159 dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);160 var profile = Mock.Of<IFailureReportProfile>(p =>161 p.MaxSampleItem == max162 && p.ThresholdSampleItem == threshold163 && p.ExpectedSet == FailureReportSetType.Full164 );165 var samplers = new SamplersFactory<DataRow>().Instantiate(profile);166 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);167 msg.BuildComparaison(dataTable.Rows.Cast<DataRow>(), null, null);168 var value = msg.RenderExpected();169 var lines = value.Replace("\n", string.Empty).Split('\r');170 171 Assert.That(lines.Count(l => l.Contains("|")), Is.EqualTo(rowCount + 3));172 }173 [Test]174 public void RenderExpected_MoreThanSampleRowsCountButLessThanMaxRowsCountWithSpecificProfileNone_ReturnEachRowAndHeaderAndSeparation()175 {176 var rowCount = 120;177 var threshold = rowCount - 20;178 var max = threshold / 2;179 var dataSet = new DataSet();180 var dataTable = new DataTable() { TableName = "MyTable" };181 dataTable.Columns.Add(new DataColumn("Id"));182 dataTable.Columns.Add(new DataColumn("Numeric value"));183 dataTable.Columns.Add(new DataColumn("Boolean value"));184 for (int i = 0; i < rowCount; i++)185 dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);186 var profile = Mock.Of<IFailureReportProfile>(p =>187 p.MaxSampleItem == max188 && p.ThresholdSampleItem == threshold189 && p.ExpectedSet == FailureReportSetType.None190 );191 var samplers = new SamplersFactory<DataRow>().Instantiate(profile);192 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);193 msg.BuildComparaison(dataTable.Rows.Cast<DataRow>(), null, null);194 var value = msg.RenderExpected();195 var lines = value.Replace("\n", string.Empty).Split('\r');196 Assert.That(lines.Count(l => l.Contains("|")), Is.EqualTo(0));197 Assert.That(lines, Has.All.EqualTo("Display skipped."));198 }199 [Test]200 public void RenderExpected_MoreThanMaxRowsCount_ReturnCorrectCountOfSkippedRow()201 {202 var dataTable = new DataTable() { TableName = "MyTable" };203 dataTable.Columns.Add(new DataColumn("Id"));204 dataTable.Columns.Add(new DataColumn("Numeric value"));205 dataTable.Columns.Add(new DataColumn("Boolean value"));206 for (int i = 0; i < 22; i++)207 dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);208 var samplers = new SamplersFactory<DataRow>().Instantiate(FailureReportProfile.Default);209 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);210 msg.BuildComparaison(dataTable.Rows.Cast<DataRow>(), null, null);211 var value = msg.RenderExpected();212 var lines = value.Replace("\n", string.Empty).Split('\r');213 //Not exactly the last line but the previous due to paragraph rendering.214 var lastLine = lines.Reverse().ElementAt(1);215 Assert.That(lastLine, Is.EqualTo("12 (of 22) rows have been skipped for display purpose."));216 }217 [Test]218 [TestCase(5)]219 [TestCase(12)]220 public void RenderExpected_LessThanMaxRowsCount_DoesntDisplaySkippedRow(int rowCount)221 {222 var dataTable = new DataTable() { TableName = "MyTable" };223 dataTable.Columns.Add(new DataColumn("Id"));224 dataTable.Columns.Add(new DataColumn("Numeric value"));225 dataTable.Columns.Add(new DataColumn("Boolean value"));226 for (int i = 0; i < rowCount; i++)227 dataTable.LoadDataRow(new object[] { "Alpha", i, true }, false);228 var samplers = new SamplersFactory<DataRow>().Instantiate(FailureReportProfile.Default);229 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);230 msg.BuildComparaison(dataTable.Rows.Cast<DataRow>(), null, null);231 var value = msg.RenderExpected();232 Assert.That(value, Does.Not.Contain("rows have been skipped for display purpose."));233 }234 [Test]235 [TestCase(0, 5, 5, 5, 5, "Missing rows:")]236 [TestCase(5, 0, 5, 5, 5, "Unexpected rows:")]237 [TestCase(5, 5, 0, 5, 5, "Duplicated rows:")]238 [TestCase(5, 5, 5, 5, 0, "Non matching value rows:")]239 public void RenderCompared_NoSpecialRows_DoesntDisplayTextForThisKindOfRows(240 int missingRowCount241 , int unexpectedRowCount242 , int duplicatedRowCount243 , int keyMatchingRowCount244 , int nonMatchingValueRowCount245 , string unexpectedText)246 {247 var compared = ResultResultSet.Build(248 GetDataRows(missingRowCount)249 , GetDataRows( unexpectedRowCount)250 , GetDataRows( duplicatedRowCount)251 , GetDataRows( keyMatchingRowCount)252 , GetDataRows( nonMatchingValueRowCount)253 );254 var samplers = new SamplersFactory<DataRow>().Instantiate(FailureReportProfile.Default);255 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);256 msg.BuildComparaison(null, null, compared);257 var value = msg.RenderAnalysis();258 Assert.That(value, Does.Not.Contain(unexpectedText));259 }260 [Test]261 [TestCase(3, 0, 0, 0, 0, "Missing rows:")]262 [TestCase(0, 3, 0, 0, 0, "Unexpected rows:")]263 [TestCase(0, 0, 3, 0, 0, "Duplicated rows:")]264 [TestCase(0, 0, 0, 0, 3, "Non matching value rows:")]265 public void RenderCompared_WithSpecialRows_DisplayTextForThisKindOfRows(266 int missingRowCount267 , int unexpectedRowCount268 , int duplicatedRowCount269 , int keyMatchingRowCount270 , int nonMatchingValueRowCount271 , string expectedText)272 {273 var compared = ResultResultSet.Build(274 GetDataRows(missingRowCount)275 , GetDataRows(unexpectedRowCount)276 , GetDataRows(duplicatedRowCount)277 , GetDataRows(keyMatchingRowCount)278 , GetDataRows(nonMatchingValueRowCount)279 );280 var samplers = new SamplersFactory<DataRow>().Instantiate(FailureReportProfile.Default);281 var msg = new DataRowsMessageMarkdown(EngineStyle.ByIndex, samplers);282 msg.BuildComparaison(null, null, compared);283 var value = msg.RenderAnalysis();284 Assert.That(value, Does.Contain(expectedText));285 }286 }287}...

Full Screen

Full Screen

DataRowsMessageMarkdown.cs

Source:DataRowsMessageMarkdown.cs Github

copy

Full Screen

...9using NBi.Framework.Sampling;10using NBi.Core.ResultSet.Uniqueness;11namespace NBi.Framework.FailureMessage.Markdown12{13 class DataRowsMessageMarkdown : IDataRowsMessageFormatter14 {15 private readonly IDictionary<string, ISampler<DataRow>> samplers;16 private readonly EngineStyle style;17 private MarkdownContainer expected;18 private MarkdownContainer actual;19 private MarkdownContainer analysis;20 public DataRowsMessageMarkdown(EngineStyle style, IDictionary<string, ISampler<DataRow>> samplers)21 {22 this.style = style;23 this.samplers = samplers;24 }25 public void BuildComparaison(IEnumerable<DataRow> expectedRows, IEnumerable<DataRow> actualRows, ResultResultSet compareResult)26 {27 compareResult = compareResult ?? ResultResultSet.Build(new List<DataRow>(), new List<DataRow>(), new List<DataRow>(), new List<DataRow>(), new List<DataRow>());28 expected = BuildTable(style, expectedRows, samplers["expected"]);29 actual = BuildTable(style, actualRows, samplers["actual"]);30 analysis = BuildNonEmptyTable(style, compareResult.Unexpected, "Unexpected", samplers["analysis"]);31 analysis.Append(BuildNonEmptyTable(style, compareResult.Missing ?? new List<DataRow>(), "Missing", samplers["analysis"]));32 analysis.Append(BuildNonEmptyTable(style, compareResult.Duplicated ?? new List<DataRow>(), "Duplicated", samplers["analysis"]));33 analysis.Append(BuildCompareTable(style, compareResult.NonMatchingValue.Rows ?? new List<DataRow>(), "Non matching value", samplers["analysis"]));34 }...

Full Screen

Full Screen

DataRowsMessageFormatterFactory.cs

Source:DataRowsMessageFormatterFactory.cs Github

copy

Full Screen

...19 var samplers = factory.Instantiate(profile);20 switch (profile.Format)21 {22 case FailureReportFormat.Markdown:23 return new DataRowsMessageMarkdown(style, samplers);24 case FailureReportFormat.Json:25 return new DataRowsMessageJson(style, samplers);26 default:27 throw new ArgumentOutOfRangeException();28 }29 30 }31 }32}...

Full Screen

Full Screen

DataRowsMessageMarkdown

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.ResultSet;7using NBi.Framework.FailureMessage.Markdown;8using NBi.Core;9using NBi.Core.ResultSet.Comparer;10{11 {12 static void Main(string[] args)13 {14 var rows = new List<DataRow>();15 rows.Add(new DataRow(new object[] { "1", "2", "3" }, DataRowState.Ko));16 rows.Add(new DataRow(new object[] { "4", "5", "6" }, DataRowState.Ko));17 rows.Add(new DataRow(new object[] { "7", "8", "9" }, DataRowState.Ko));18 var comparer = new ToleranceResultSetComparer(0.0001, ToleranceType.Absolute);19 var rs = new ResultSet(rows, new[] { "Col1", "Col2", "Col3" });20 var msg = new DataRowsMessageMarkdown(rs, comparer);21 Console.WriteLine(msg.ToString());22 Console.ReadLine();23 }24 }25}

Full Screen

Full Screen

DataRowsMessageMarkdown

Using AI Code Generation

copy

Full Screen

1var dataRowsMessageMarkdown = new DataRowsMessageMarkdown();2var dataRows = new List<DataRow>();3var dataRow = new DataRow();4dataRow["col1"] = "value1";5dataRow["col2"] = "value2";6dataRows.Add(dataRow);7var markdown = dataRowsMessageMarkdown.Execute(dataRows);8Console.WriteLine(markdown);

Full Screen

Full Screen

DataRowsMessageMarkdown

Using AI Code Generation

copy

Full Screen

1var markdown = new DataRowsMessageMarkdown();2markdown.DataRows = dataRows;3markdown.DataRowsLimit = 10;4markdown.DataRowsOffset = 0;5markdown.Expected = expected;6markdown.Actual = actual;7markdown.Header = "My header";8markdown.Footer = "My footer";9markdown.Caption = "My caption";10markdown.CaptionLimit = 10;11markdown.CaptionOffset = 0;12markdown.CaptionFooter = "My caption footer";13markdown.CaptionHeader = "My caption header";14markdown.CaptionSeparator = " | ";15markdown.CaptionColumnSeparator = " | ";16markdown.CaptionRowSeparator = " | ";17markdown.CaptionColumnWidth = 10;18markdown.CaptionColumnAlignment = Alignment.Left;19markdown.CaptionColumnPadding = 1;20markdown.CaptionColumnPaddingChar = ' ';

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful