How to use GetColumns method of NBi.Core.ResultSet.Lookup.CellRetrieverByName class

Best NBi code snippet using NBi.Core.ResultSet.Lookup.CellRetrieverByName.GetColumns

CellsRetrieverByNameTest.cs

Source:CellsRetrieverByNameTest.cs Github

copy

Full Screen

...38 {39 new Column() { Identifier = new ColumnNameIdentifier("zero"), Type=ColumnType.Text}40 };41 var keyRetriever = new CellRetrieverByName(columns);42 Assert.That(keyRetriever.GetColumns(table.Rows[0]).Members, Is.EqualTo(new[] { "Key0" }));43 Assert.That(keyRetriever.GetColumns(table.Rows[1]).Members, Is.EqualTo(new[] { "Key1" }));44 Assert.That(keyRetriever.GetColumns(table.Rows[2]).Members, Is.EqualTo(new[] { "Key0" }));45 }46 [Test]47 public void GetKeys_UniqueCellNumeric_CorrectCell()48 {49 var table = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 0 });50 var columns = new List<IColumnDefinition>()51 {52 new Column() { Identifier = new ColumnNameIdentifier("two"), Type=ColumnType.Numeric}53 };54 var keyRetriever = new CellRetrieverByName(columns);55 Assert.That(keyRetriever.GetColumns(table.Rows[0]).Members, Is.EqualTo(new[] { 0 }));56 Assert.That(keyRetriever.GetColumns(table.Rows[1]).Members, Is.EqualTo(new[] { 1 }));57 Assert.That(keyRetriever.GetColumns(table.Rows[2]).Members, Is.EqualTo(new[] { 0 }));58 }59 [Test]60 public void GetKeys_UniqueCellNumericCasting_CorrectCell()61 {62 var table = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { "0", "1.0", "0.00" });63 var columns = new List<IColumnDefinition>()64 {65 new Column() { Identifier = new ColumnNameIdentifier("two"), Type=ColumnType.Numeric}66 };67 var keyRetriever = new CellRetrieverByName(columns);68 Assert.That(keyRetriever.GetColumns(table.Rows[0]).Members, Is.EqualTo(new[] { 0 }));69 Assert.That(keyRetriever.GetColumns(table.Rows[1]).Members, Is.EqualTo(new[] { 1 }));70 Assert.That(keyRetriever.GetColumns(table.Rows[2]).Members, Is.EqualTo(new[] { 0 }));71 }72 [Test]73 public void GetKeys_TwoCells_CorrectCells()74 {75 var table = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 0 });76 var columns = new List<IColumnDefinition>()77 {78 new Column() { Identifier = new ColumnNameIdentifier("zero"), Type=ColumnType.Text},79 new Column() { Identifier = new ColumnNameIdentifier("one"), Type=ColumnType.Text}80 };81 var keyRetriever = new CellRetrieverByName(columns);82 Assert.That(keyRetriever.GetColumns(table.Rows[0]).Members, Is.EqualTo(new[] { "Key0", "Foo" }));83 Assert.That(keyRetriever.GetColumns(table.Rows[1]).Members, Is.EqualTo(new[] { "Key1", "Bar" }));84 Assert.That(keyRetriever.GetColumns(table.Rows[2]).Members, Is.EqualTo(new[] { "Key0", "Foo" }));85 }86 [Test]87 public void GetKeys_TwoCellsDifferentTypes_CorrectCells()88 {89 var table = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 0 });90 var columns = new List<IColumnDefinition>()91 {92 new Column() { Identifier = new ColumnNameIdentifier("zero"), Type=ColumnType.Text},93 new Column() { Identifier = new ColumnNameIdentifier("two"), Type=ColumnType.Numeric}94 };95 var keyRetriever = new CellRetrieverByName(columns);96 Assert.That(keyRetriever.GetColumns(table.Rows[0]).Members, Is.EqualTo(new object[] { "Key0", 0 }));97 Assert.That(keyRetriever.GetColumns(table.Rows[1]).Members, Is.EqualTo(new object[] { "Key1", 1 }));98 Assert.That(keyRetriever.GetColumns(table.Rows[2]).Members, Is.EqualTo(new object[] { "Key0", 0 }));99 }100 [Test]101 public void GetKeys_TwoCellsReverseOrder_CorrectCells()102 {103 var table = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 0 });104 var columns = new List<IColumnDefinition>()105 {106 new Column() { Identifier = new ColumnNameIdentifier("one"), Type=ColumnType.Text},107 new Column() { Identifier = new ColumnNameIdentifier("zero"), Type=ColumnType.Text}108 };109 var keyRetriever = new CellRetrieverByName(columns);110 Assert.That(keyRetriever.GetColumns(table.Rows[0]).Members, Is.EqualTo(new[] { "Foo", "Key0" }));111 Assert.That(keyRetriever.GetColumns(table.Rows[1]).Members, Is.EqualTo(new[] { "Bar", "Key1" }));112 Assert.That(keyRetriever.GetColumns(table.Rows[2]).Members, Is.EqualTo(new[] { "Foo", "Key0" }));113 }114 [Test]115 public void GetKeys_NonExistingCell_CorrectMessage()116 {117 var table = BuildDataTable(new[] { "Key0", "Key1", "Key0" }, new[] { "Foo", "Bar", "Foo" }, new object[] { 0, 1, 0 });118 var columns = new List<IColumnDefinition>()119 {120 new Column() { Identifier = new ColumnNameIdentifier("notExisting"), Type=ColumnType.Text},121 new Column() { Identifier = new ColumnNameIdentifier("zero"), Type=ColumnType.Text}122 };123 var keyRetriever = new CellRetrieverByName(columns);124 var ex = Assert.Throws<NBiException>(() => keyRetriever.GetColumns(table.Rows[0]));125 Assert.That(ex.Message, Does.Contain(": 'zero', 'one', 'two'."));126 }127 }128}...

Full Screen

Full Screen

LookupExistsAnalyzer.cs

Source:LookupExistsAnalyzer.cs Github

copy

Full Screen

...55 {56 var references = new HashSet<KeyCollection>();57 foreach (DataRow row in table.Rows)58 {59 var keys = keyRetriever.GetColumns(row);60 if (!references.Contains(keys))61 references.Add(keys);62 }63 return references;64 }65 protected virtual LookupViolationCollection ExtractLookupViolation(DataTable table, CellRetriever keyRetriever, IEnumerable<KeyCollection> references)66 {67 var violations = new LookupExistsViolationCollection(Keys);68 var stopWatch = new Stopwatch();69 stopWatch.Start();70 var i = 0;71 foreach (DataRow row in table.Rows)72 {73 i++;74 75 var keys = keyRetriever.GetColumns(row);76 if (!references.Contains(keys))77 violations.Register(keys, row);78 if (i % 1000 == 0)79 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, $"Searching for {i} rows [{stopWatch.Elapsed:d'.'hh':'mm':'ss'.'fff'ms'}]");80 }81 return violations;82 }83 }84}...

Full Screen

Full Screen

CellRetrieverByName.cs

Source:CellRetrieverByName.cs Github

copy

Full Screen

...11 {12 public CellRetrieverByName(IEnumerable<IColumnDefinition> settings)13 : base(settings)14 { }15 public override KeyCollection GetColumns(DataRow row)16 {17 var keys = new List<object>();18 foreach (var setting in Settings)19 {20 var name = (setting.Identifier as ColumnNameIdentifier).Name;21 try22 {23 var value = FormatValue(setting.Type, row[name]);24 keys.Add(value);25 }26 catch (ArgumentException ex)27 {28 var columnNames = row.Table.Columns.Cast<DataColumn>().Select(x => x.ColumnName);29 throw new NBiException($"{ex.Message} This table contains the following column{(columnNames.Count()>1 ? "s" : string.Empty)}: '{string.Join("', '", columnNames)}'.");...

Full Screen

Full Screen

GetColumns

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.Lookup;7using NBi.Core.ResultSet;8{9 {10 static void Main(string[] args)11 {12 var columnNames = new string[2] { "First", "Second" };13 var columnTypes = new ColumnType[2] { ColumnType.Numeric, ColumnType.Text };14 var cellRetriever = new CellRetrieverByName(columnNames, columnTypes);15 var columns = cellRetriever.GetColumns();16 Console.WriteLine("First column is of type {0} and second column is of type {1}", columns[0].Type, columns[1].Type);17 Console.ReadLine();18 }19 }20}21using System;22using System.Collections.Generic;23using System.Linq;24using System.Text;25using System.Threading.Tasks;26using NBi.Core.ResultSet.Lookup;27using NBi.Core.ResultSet;28{29 {30 static void Main(string[] args)31 {32 var columnNames = new string[2] { "First", "Second" };33 var columnTypes = new ColumnType[2] { ColumnType.Numeric, ColumnType.Text };34 var cellRetriever = new CellRetrieverByIndex(columnNames, columnTypes);35 var columns = cellRetriever.GetColumns();36 Console.WriteLine("First column is of type {0} and second column is of type {1}", columns[0].Type, columns[1].Type);37 Console.ReadLine();38 }39 }40}41using System;42using System.Collections.Generic;43using System.Linq;44using System.Text;45using System.Threading.Tasks;46using NBi.Core.ResultSet.Lookup;47using NBi.Core.ResultSet;48{49 {50 static void Main(string[] args)51 {52 var columnNames = new string[2] { "First", "Second" };

Full Screen

Full Screen

GetColumns

Using AI Code Generation

copy

Full Screen

1NBi.Core.ResultSet.Lookup.CellRetrieverByName cellRetrieverByName = new NBi.Core.ResultSet.Lookup.CellRetrieverByName();2var column = cellRetrieverByName.GetColumns(new NBi.Core.ResultSet.ResultSet(), "column1");3NBi.Core.ResultSet.Lookup.CellRetrieverByName cellRetrieverByName = new NBi.Core.ResultSet.Lookup.CellRetrieverByName();4var column = cellRetrieverByName.GetColumns(new NBi.Core.ResultSet.ResultSet(), "column1");5NBi.Core.ResultSet.Lookup.CellRetrieverByName cellRetrieverByName = new NBi.Core.ResultSet.Lookup.CellRetrieverByName();6var column = cellRetrieverByName.GetColumns(new NBi.Core.ResultSet.ResultSet(), "column1");7NBi.Core.ResultSet.Lookup.CellRetrieverByName cellRetrieverByName = new NBi.Core.ResultSet.Lookup.CellRetrieverByName();8var column = cellRetrieverByName.GetColumns(new NBi.Core.ResultSet.ResultSet(), "column1");9NBi.Core.ResultSet.Lookup.CellRetrieverByName cellRetrieverByName = new NBi.Core.ResultSet.Lookup.CellRetrieverByName();10var column = cellRetrieverByName.GetColumns(new NBi.Core.ResultSet.ResultSet(), "column1");11NBi.Core.ResultSet.Lookup.CellRetrieverByName cellRetrieverByName = new NBi.Core.ResultSet.Lookup.CellRetrieverByName();12var column = cellRetrieverByName.GetColumns(new NBi.Core.ResultSet.ResultSet(), "column1");13NBi.Core.ResultSet.Lookup.CellRetrieverByName cellRetrieverByName = new NBi.Core.ResultSet.Lookup.CellRetrieverByName();14var column = cellRetrieverByName.GetColumns(new NBi.Core

Full Screen

Full Screen

GetColumns

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using NBi.Core.ResultSet;6using NBi.Core.ResultSet.Lookup;7using NBi.Core.ResultSet.Lookup.Violation;8using NBi.Core.Calculation;9{10 {11 static void Main(string[] args)12 {13 var rows = new List<IRow>();14 var row = new Row();15 row.Cells = new List<ICell>() { new Cell("A"), new Cell("B"), new Cell("C"), new Cell("D") };16 rows.Add(row);17 row = new Row();18 row.Cells = new List<ICell>() { new Cell("A"), new Cell("B"), new Cell("C"), new Cell("D") };19 rows.Add(row);20 row = new Row();21 row.Cells = new List<ICell>() { new Cell("A"), new Cell("B"), new Cell("C"), new Cell("D") };22 rows.Add(row);23 row = new Row();24 row.Cells = new List<ICell>() { new Cell("A"), new Cell("B"), new Cell("C"), new Cell("D") };25 rows.Add(row);26 row = new Row();27 row.Cells = new List<ICell>() { new Cell("A"), new Cell("B"), new Cell("C"), new Cell("D") };28 rows.Add(row);29 row = new Row();30 row.Cells = new List<ICell>() { new Cell("A"), new Cell("B"), new Cell("C"), new Cell("D") };31 rows.Add(row);32 row = new Row();33 row.Cells = new List<ICell>() { new Cell("A"), new Cell("B"), new Cell("C"), new Cell("D") };34 rows.Add(row);35 row = new Row();36 row.Cells = new List<ICell>() { new Cell("A"), new Cell("B"), new Cell("C"), new Cell("D") };37 rows.Add(row);38 row = new Row();39 row.Cells = new List<ICell>() { new Cell("A"), new Cell("B"), new Cell("C"), new Cell("D") };40 rows.Add(row);41 row = new Row();42 row.Cells = new List<ICell>() { new Cell("A"), new Cell

Full Screen

Full Screen

GetColumns

Using AI Code Generation

copy

Full Screen

1using System;2using NBi.Core.ResultSet;3using NBi.Core.ResultSet.Lookup;4using System.Data;5using System.Collections.Generic;6{7 {8 static void Main(string[] args)9 {10 var rs = new ResultSet();11 var rsCol1 = new ResultSetColumn("column1");12 var rsCol2 = new ResultSetColumn("column2");13 var rsCol3 = new ResultSetColumn("column3");14 rs.Columns.Add(rsCol1);15 rs.Columns.Add(rsCol2);16 rs.Columns.Add(rsCol3);17 var row = new object[] { 1, 2, 3 };18 rs.Load(row);19 var columnNames = new List<string>();20 columnNames.Add("column1");21 columnNames.Add("column3");22 var cellRetrieverByName = new CellRetrieverByName(rs);23 var columns = cellRetrieverByName.GetColumns(columnNames);24 var columnNamesFromColumns = new List<string>();25 foreach (var col in columns)26 {27 columnNamesFromColumns.Add(col.ColumnName);28 }29 Console.WriteLine(string.Join(",", columnNamesFromColumns));30 Console.ReadLine();31 }32 }33}

Full Screen

Full Screen

GetColumns

Using AI Code Generation

copy

Full Screen

1var retriever = new NBi.Core.ResultSet.Lookup.CellRetrieverByName();2var retriever = new NBi.Core.ResultSet.Lookup.CellRetrieverByOrdinal();3using System.IO;4var csvData = File.ReadAllText("SampleData.csv");5var rs = new NBi.Core.ResultSet.ResultSet();6rs.Load(csvData, new NBi.Core.ResultSet.CsvProfile());7var retriever = new NBi.Core.ResultSet.Lookup.CellRetrieverByName();8var columns = retriever.GetColumns(rs, "Name", "Address");

Full Screen

Full Screen

GetColumns

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using System.Data;7using NBi.Core.ResultSet.Lookup;8{9 {10 static void Main(string[] args)11 {12 DataTable result = new DataTable();13 string[] columns = CellRetrieverByName.GetColumns(result);14 }15 }16}

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 method in CellRetrieverByName

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful