How to use LookupMatchesViolationData class of NBi.Core.ResultSet.Lookup.Violation package

Best NBi code snippet using NBi.Core.ResultSet.Lookup.Violation.LookupMatchesViolationData

LookupTableHelperMarkdownTest.cs

Source:LookupTableHelperMarkdownTest.cs Github

copy

Full Screen

...30 var records = new List<LookupMatchesViolationRecord>()31 {32 new LookupMatchesViolationRecord()33 {34 { candidateTable.Columns[1] , new LookupMatchesViolationData(false, 15) },35 },36 };37 var association = new LookupMatchesViolationComposite(candidateTable.Rows[0], records);38 var sampler = new FullSampler<LookupMatchesViolationComposite>();39 sampler.Build(new[] { association });40 var msg = new LookupTableHelperMarkdown(new[] { association }41 , new[] { foreignKeyDefinition, numericDefinition }42 , sampler);43 var container = new MarkdownContainer();44 msg.Render(container);45 var value = container.ToMarkdown();46 Assert.That(value.Count(c => c == '\n'), Is.EqualTo(6));47 var indexes = value.IndexOfAll('\n').ToArray();48 var dashLine = value.Substring(indexes[3] + 1, indexes[4] - indexes[3] - 2);49 Assert.That(dashLine.Distinct().Count(), Is.EqualTo(3));50 Assert.That(dashLine.Distinct(), Has.Member(' '));51 Assert.That(dashLine.Distinct(), Has.Member('-'));52 Assert.That(dashLine.Distinct(), Has.Member('|'));53 }54 [Test]55 public void Render_OneViolationWithOneRecordOfTwoWrongFields_Correct()56 {57 var candidateTable = new DataTable() { TableName = "MyTable" };58 candidateTable.Columns.Add(new DataColumn("Id"));59 candidateTable.Columns.Add(new DataColumn("ForeignKey"));60 candidateTable.Columns.Add(new DataColumn("Numeric value"));61 candidateTable.Columns.Add(new DataColumn("Boolean value"));62 candidateTable.LoadDataRow(new object[] { 1, "Alpha", 10, true }, false);63 candidateTable.LoadDataRow(new object[] { 2, "Beta", 20, false }, false);64 var foreignKeyDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("ForeignKey"), Role = ColumnRole.Key };65 var numericDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("Numeric value"), Role = ColumnRole.Value };66 var booleanDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("Boolean value"), Role = ColumnRole.Value };67 var records = new List<LookupMatchesViolationRecord>()68 {69 new LookupMatchesViolationRecord()70 {71 { candidateTable.Columns[2] , new LookupMatchesViolationData(false, 15) },72 { candidateTable.Columns[3] , new LookupMatchesViolationData(false, false) },73 },74 };75 var association = new LookupMatchesViolationComposite(candidateTable.Rows[0], records);76 var sampler = new FullSampler<LookupMatchesViolationComposite>();77 sampler.Build(new[] { association });78 var msg = new LookupTableHelperMarkdown(new[] { association }79 , new[] { foreignKeyDefinition, numericDefinition, booleanDefinition }80 , sampler);81 var container = new MarkdownContainer();82 msg.Render(container);83 var value = container.ToMarkdown();84 Assert.That(value.Count(c => c == '\n'), Is.EqualTo(6));85 Assert.That(value, Does.Contain("| 10 <> 15"));86 Assert.That(value, Does.Contain("| True <> False"));87 }88 [Test]89 public void Render_OneViolationWithOneRecordOfOneCorrectAndOneWrongField_Correct()90 {91 var candidateTable = new DataTable() { TableName = "MyTable" };92 candidateTable.Columns.Add(new DataColumn("Id"));93 candidateTable.Columns.Add(new DataColumn("ForeignKey"));94 candidateTable.Columns.Add(new DataColumn("Numeric value"));95 candidateTable.Columns.Add(new DataColumn("Boolean value"));96 candidateTable.LoadDataRow(new object[] { 1, "Alpha", 10, true }, false);97 candidateTable.LoadDataRow(new object[] { 2, "Beta", 20, false }, false);98 var foreignKeyDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("ForeignKey"), Role = ColumnRole.Key };99 var numericDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("Numeric value"), Role = ColumnRole.Value, Type = ColumnType.Numeric };100 var booleanDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("Boolean value"), Role = ColumnRole.Value, Type = ColumnType.Boolean };101 var records = new List<LookupMatchesViolationRecord>()102 {103 new LookupMatchesViolationRecord()104 {105 { candidateTable.Columns[3] , new LookupMatchesViolationData(false, false) },106 },107 };108 var association = new LookupMatchesViolationComposite(candidateTable.Rows[0], records);109 var sampler = new FullSampler<LookupMatchesViolationComposite>();110 sampler.Build(new[] { association });111 var msg = new LookupTableHelperMarkdown(new[] { association }112 , new[] { foreignKeyDefinition, numericDefinition, booleanDefinition }113 , sampler);114 var container = new MarkdownContainer();115 msg.Render(container);116 var value = container.ToMarkdown();117 Assert.That(value.Count(c => c == '\n'), Is.EqualTo(6));118 Assert.That(value, Does.Contain("| 10 "));119 Assert.That(value, Does.Contain("| True <> False"));120 }121 [Test]122 public void Render_OneViolationWithThreeRecordOfTwoFields_Correct()123 {124 var candidateTable = new DataTable() { TableName = "MyTable" };125 candidateTable.Columns.Add(new DataColumn("Id"));126 candidateTable.Columns.Add(new DataColumn("ForeignKey"));127 candidateTable.Columns.Add(new DataColumn("Numeric value"));128 candidateTable.Columns.Add(new DataColumn("Boolean value"));129 candidateTable.LoadDataRow(new object[] { 1, "Alpha", 10, true }, false);130 candidateTable.LoadDataRow(new object[] { 2, "Beta", 20, false }, false);131 var foreignKeyDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("ForeignKey"), Role = ColumnRole.Key };132 var numericDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("Numeric value"), Role = ColumnRole.Value, Type = ColumnType.Numeric };133 var booleanDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("Boolean value"), Role = ColumnRole.Value, Type = ColumnType.Boolean };134 var records = new List<LookupMatchesViolationRecord>()135 {136 new LookupMatchesViolationRecord()137 {138 { candidateTable.Columns[2] , new LookupMatchesViolationData(true, "10.0") },139 { candidateTable.Columns[3] , new LookupMatchesViolationData(false, false) },140 },141 new LookupMatchesViolationRecord()142 {143 { candidateTable.Columns[2] , new LookupMatchesViolationData(false, "12") },144 { candidateTable.Columns[3] , new LookupMatchesViolationData(false, false) },145 },146 new LookupMatchesViolationRecord()147 {148 { candidateTable.Columns[2] , new LookupMatchesViolationData(false, "18") },149 { candidateTable.Columns[3] , new LookupMatchesViolationData(true, true) },150 },151 };152 var association = new LookupMatchesViolationComposite(candidateTable.Rows[0], records);153 var sampler = new FullSampler<LookupMatchesViolationComposite>();154 sampler.Build(new[] { association });155 var msg = new LookupTableHelperMarkdown(new[] { association }156 , new[] { foreignKeyDefinition, numericDefinition, booleanDefinition }157 , sampler);158 var container = new MarkdownContainer();159 msg.Render(container);160 var value = container.ToMarkdown();161 Assert.That(value.Count(c => c == '\n'), Is.EqualTo(8));162 Assert.That(value, Does.Contain("| 10 "));163 Assert.That(value, Does.Contain("| True <> False"));164 Assert.That(value, Does.Contain("| 10 <> 12 "));165 Assert.That(value, Does.Contain("| True <> False"));166 Assert.That(value, Does.Contain("| 10 <> 18 "));167 Assert.That(value, Does.Contain("| True "));168 }169 [Test]170 public void Render_TwoViolationsForSameKey_Correct()171 {172 var candidateTable = new DataTable() { TableName = "MyTable" };173 candidateTable.Columns.Add(new DataColumn("Id"));174 candidateTable.Columns.Add(new DataColumn("ForeignKey"));175 candidateTable.Columns.Add(new DataColumn("Numeric value"));176 candidateTable.Columns.Add(new DataColumn("Boolean value"));177 candidateTable.LoadDataRow(new object[] { 1, "Alpha", 10, true }, false);178 candidateTable.LoadDataRow(new object[] { 2, "Alpha", 20, false }, false);179 var foreignKeyDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("ForeignKey"), Role = ColumnRole.Key };180 var numericDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("Numeric value"), Role = ColumnRole.Value, Type = ColumnType.Numeric };181 var booleanDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("Boolean value"), Role = ColumnRole.Value, Type = ColumnType.Boolean };182 var records = new List<LookupMatchesViolationRecord>()183 {184 new LookupMatchesViolationRecord()185 {186 { candidateTable.Columns[2] , new LookupMatchesViolationData(false, "17.0") },187 { candidateTable.Columns[3] , new LookupMatchesViolationData(false, false) },188 },189 new LookupMatchesViolationRecord()190 {191 { candidateTable.Columns[2] , new LookupMatchesViolationData(false, "12") },192 { candidateTable.Columns[3] , new LookupMatchesViolationData(false, false) },193 },194 new LookupMatchesViolationRecord()195 {196 { candidateTable.Columns[2] , new LookupMatchesViolationData(false, "18") },197 { candidateTable.Columns[3] , new LookupMatchesViolationData(true, true) },198 },199 };200 var firstAssociation = new LookupMatchesViolationComposite(candidateTable.Rows[0], records);201 var secondAssociation = new LookupMatchesViolationComposite(candidateTable.Rows[1], records);202 var sampler = new FullSampler<LookupMatchesViolationComposite>();203 sampler.Build(new[] { firstAssociation, secondAssociation });204 var msg = new LookupTableHelperMarkdown(new[] { firstAssociation, secondAssociation }205 , new[] { foreignKeyDefinition, numericDefinition, booleanDefinition }206 , sampler);207 var container = new MarkdownContainer();208 msg.Render(container);209 var value = container.ToMarkdown();210 Assert.That(value.Count(c => c == '\n'), Is.EqualTo(11));211 Assert.That(value, Does.Contain("Result-set with 2 rows"));...

Full Screen

Full Screen

LookupMatchesViolationMessageJsonTest.cs

Source:LookupMatchesViolationMessageJsonTest.cs Github

copy

Full Screen

...54 var information = new LookupMatchesViolationInformation(RowViolationState.Mismatch);55 information.AddCandidateRow(candidateTable.Rows[0]);56 information.CandidateRows.ElementAt(0).Records.Add(new LookupMatchesViolationRecord()57 {58 { candidateTable.Columns[1] , new LookupMatchesViolationData(false, 15) },59 });60 var violations = new LookupMatchesViolationCollection(keyMappings, valueMappings)61 {62 { new KeyCollection(new[] { "Alpha" }), information }63 };64 var samplers = new Dictionary<string, ISampler<DataRow>>()65 {66 { "candidate", new FullSampler<DataRow>() },67 { "reference", new FullSampler<DataRow>() },68 { "analysis", new FullSampler<DataRow>() },69 };70 var message = new LookupMatchesViolationMessageJson(samplers);71 message.Generate(referenceTable.Rows.Cast<DataRow>(), candidateTable.Rows.Cast<DataRow>(), violations, keyMappings, valueMappings);72 var text = message.RenderMessage();73 Assert.That(text, Does.Contain("\"expected\":{\"total-rows\":3,\"table\""));74 Assert.That(text, Does.Contain("\"actual\":{\"total-rows\":2,\"table\""));75 Assert.That(text, Does.Contain("\"analysis\":{\"non-matching\":{\"total-rows\":1,"));76 Assert.That(text, Does.Contain(",{\"value\":\"10\",\"expectation\":\"15\"},"));77 }78 [Test]79 public void RenderMessage_NoneSamples_Correct()80 {81 var referenceTable = new DataTable() { TableName = "MyTable" };82 referenceTable.Columns.Add(new DataColumn("ForeignKey"));83 referenceTable.Columns.Add(new DataColumn("Numeric value"));84 referenceTable.LoadDataRow(new object[] { "Alpha", 15 }, false);85 referenceTable.LoadDataRow(new object[] { "Beta", 20 }, false);86 referenceTable.LoadDataRow(new object[] { "Beta", 20 }, false);87 var candidateTable = new DataTable() { TableName = "MyTable" };88 candidateTable.Columns.Add(new DataColumn("ForeignKey"));89 candidateTable.Columns.Add(new DataColumn("Numeric value"));90 candidateTable.Columns.Add(new DataColumn("Boolean value"));91 candidateTable.LoadDataRow(new object[] { "Alpha", 10, true }, false);92 candidateTable.LoadDataRow(new object[] { "Beta", 20, false }, false);93 var foreignKeyDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("ForeignKey"), Role = ColumnRole.Key };94 var numericDefinition = new ColumnMetadata() { Identifier = new ColumnIdentifierFactory().Instantiate("Numeric value"), Role = ColumnRole.Value };95 var keyMappings = new ColumnMappingCollection() { new ColumnMapping(foreignKeyDefinition.Identifier, ColumnType.Text) };96 var valueMappings = new ColumnMappingCollection() { new ColumnMapping(numericDefinition.Identifier, ColumnType.Numeric) };97 var information = new LookupMatchesViolationInformation(RowViolationState.Mismatch);98 information.AddCandidateRow(candidateTable.Rows[0]);99 information.CandidateRows.ElementAt(0).Records.Add(new LookupMatchesViolationRecord()100 {101 { candidateTable.Columns[1] , new LookupMatchesViolationData(false, 15) },102 });103 var violations = new LookupMatchesViolationCollection(keyMappings, valueMappings)104 {105 { new KeyCollection(new[] { "Alpha" }), information }106 };107 var samplers = new Dictionary<string, ISampler<DataRow>>()108 {109 { "candidate", new NoneSampler<DataRow>() },110 { "reference", new NoneSampler<DataRow>() },111 { "analysis", new NoneSampler<DataRow>() },112 };113 var message = new LookupMatchesViolationMessageJson(samplers);114 message.Generate(referenceTable.Rows.Cast<DataRow>(), candidateTable.Rows.Cast<DataRow>(), violations, keyMappings, valueMappings);115 var text = message.RenderMessage();...

Full Screen

Full Screen

LookupTableHelperJsonTest.cs

Source:LookupTableHelperJsonTest.cs Github

copy

Full Screen

...33 var records = new List<LookupMatchesViolationRecord>()34 {35 new LookupMatchesViolationRecord()36 {37 { candidateTable.Columns[1] , new LookupMatchesViolationData(false, 15) },38 },39 };40 var association = new LookupMatchesViolationComposite(candidateTable.Rows[0], records);41 var sampler = new FullSampler<LookupMatchesViolationComposite>();42 sampler.Build(new[] { association });43 var msg = new LookupTableHelperJson(new[] { association }44 , new[] { foreignKeyDefinition, numericDefinition }45 , sampler);46 var sb = new StringBuilder();47 using (var sw = new StringWriter(sb))48 using (var writer = new JsonTextWriter(sw))49 {50 msg.Render(writer);51 var value = sb.ToString();...

Full Screen

Full Screen

LookupMatchesViolationData

Using AI Code Generation

copy

Full Screen

1LookupMatchesViolationData data = new LookupMatchesViolationData();2data.Add(new LookupMatchesViolationRow(1, "x", "y", "z"));3data.Add(new LookupMatchesViolationRow(2, "a", "b", "c"));4data.Add(new LookupMatchesViolationRow(3, "d", "e", "f"));5return data;6LookupMatchesViolationData data = new LookupMatchesViolationData();7data.Add(new LookupMatchesViolationRow(1, "x", "y", "z"));8data.Add(new LookupMatchesViolationRow(2, "a", "b", "c"));9data.Add(new LookupMatchesViolationRow(3, "d", "e", "f"));10return data;11LookupMatchesViolationData data = new LookupMatchesViolationData();12data.Add(new LookupMatchesViolationRow(1, "x", "y", "z"));13data.Add(new LookupMatchesViolationRow(2, "a", "b", "c"));14data.Add(new LookupMatchesViolationRow(3, "d", "e", "f"));15return data;16LookupMatchesViolationData data = new LookupMatchesViolationData();17data.Add(new LookupMatchesViolationRow(1, "x", "y", "z"));18data.Add(new LookupMatchesViolationRow(2, "a", "b", "c"));19data.Add(new LookupMatchesViolationRow(3, "d", "e", "f"));20return data;21LookupMatchesViolationData data = new LookupMatchesViolationData();22data.Add(new LookupMatchesViolationRow(1, "x", "y", "z"));23data.Add(new LookupMatchesViolationRow(2, "a", "b", "c"));24data.Add(new LookupMatchesViolationRow(3, "d", "e", "f"));25return data;

Full Screen

Full Screen

LookupMatchesViolationData

Using AI Code Generation

copy

Full Screen

1var lookupMatchesViolationData = new LookupMatchesViolationData();2lookupMatchesViolationData.Add(new LookupMatchesViolationRow(1,"A","B"));3lookupMatchesViolationData.Add(new LookupMatchesViolationRow(2,"C","D"));4lookupMatchesViolationData.Add(new LookupMatchesViolationRow(3,"E","F"));5lookupMatchesViolationData.Add(new LookupMatchesViolationRow(4,"G","H"));6lookupMatchesViolationData.Add(new LookupMatchesViolationRow(5,"I","J"));7var lookupMatchesViolationData = new LookupMatchesViolationData();8lookupMatchesViolationData.Add(new LookupMatchesViolationRow(1,"A","B"));9lookupMatchesViolationData.Add(new LookupMatchesViolationRow(2,"C","D"));10lookupMatchesViolationData.Add(new LookupMatchesViolationRow(3,"E","F"));11lookupMatchesViolationData.Add(new LookupMatchesViolationRow(4,"G","H"));12lookupMatchesViolationData.Add(new LookupMatchesViolationRow(5,"I","J"));13var lookupMatchesViolationData = new LookupMatchesViolationData();14lookupMatchesViolationData.Add(new LookupMatchesViolationRow(1,"A","B"));15lookupMatchesViolationData.Add(new LookupMatchesViolationRow(2,"C","D"));16lookupMatchesViolationData.Add(new LookupMatchesViolationRow(3,"E","F"));17lookupMatchesViolationData.Add(new LookupMatchesViolationRow(4,"G","H"));18lookupMatchesViolationData.Add(new LookupMatchesViolationRow(5,"I","J"));19var lookupMatchesViolationData = new LookupMatchesViolationData();20lookupMatchesViolationData.Add(new LookupMatchesViolationRow(1,"A","B"));21lookupMatchesViolationData.Add(new LookupMatchesViolationRow(2,"C","D"));22lookupMatchesViolationData.Add(new LookupMatchesViolationRow(3,"E","F"));23lookupMatchesViolationData.Add(new LookupMatchesViolationRow(4,"G","H"));24lookupMatchesViolationData.Add(new LookupMatchesViolationRow(5,"I","J"));

Full Screen

Full Screen

LookupMatchesViolationData

Using AI Code Generation

copy

Full Screen

1using NBi.Core.ResultSet.Lookup.Violation;2var lookupMatchesViolationData = new LookupMatchesViolationData();3lookupMatchesViolationData.AddLookupMatchesViolation(1, 2, 3);4lookupMatchesViolationData.AddLookupMatchesViolation(4, 5, 6);5lookupMatchesViolationData.AddLookupMatchesViolation(7, 8, 9);6lookupMatchesViolationData.AddLookupMatchesViolation(10, 11, 12);7lookupMatchesViolationData.AddLookupMatchesViolation(13, 14, 15);8lookupMatchesViolationData.AddLookupMatchesViolation(16, 17, 18);9lookupMatchesViolationData.AddLookupMatchesViolation(19, 20, 21);10lookupMatchesViolationData.AddLookupMatchesViolation(22, 23, 24);11lookupMatchesViolationData.AddLookupMatchesViolation(25, 26, 27);12lookupMatchesViolationData.AddLookupMatchesViolation(28, 29, 30);13lookupMatchesViolationData.AddLookupMatchesViolation(31, 32, 33);14lookupMatchesViolationData.AddLookupMatchesViolation(34, 35, 36);15lookupMatchesViolationData.AddLookupMatchesViolation(37, 38, 39);16lookupMatchesViolationData.AddLookupMatchesViolation(40, 41, 42);17lookupMatchesViolationData.AddLookupMatchesViolation(43, 44, 45);18lookupMatchesViolationData.AddLookupMatchesViolation(46, 47, 48);19lookupMatchesViolationData.AddLookupMatchesViolation(49, 50, 51);20lookupMatchesViolationData.AddLookupMatchesViolation(52, 53, 54);21lookupMatchesViolationData.AddLookupMatchesViolation(55, 56, 57);22lookupMatchesViolationData.AddLookupMatchesViolation(58, 59, 60);23lookupMatchesViolationData.AddLookupMatchesViolation(61, 62, 63);24lookupMatchesViolationData.AddLookupMatchesViolation(64, 65, 66);25lookupMatchesViolationData.AddLookupMatchesViolation(67, 68, 69);26lookupMatchesViolationData.AddLookupMatchesViolation(70, 71, 72);27lookupMatchesViolationData.AddLookupMatchesViolation(73, 74, 75);28lookupMatchesViolationData.AddLookupMatchesViolation(76, 77, 78);29lookupMatchesViolationData.AddLookupMatchesViolation(79, 80, 81);30lookupMatchesViolationData.AddLookupMatchesViolation(82, 83, 84

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.

Most used methods in LookupMatchesViolationData

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful