Best NBi code snippet using NBi.Core.ResultSet.Lookup.LookupExistsAnalyzer.BuildColumnsRetriever
LookupMatchesAnalyzer.cs
Source:LookupMatchesAnalyzer.cs
...27 protected override LookupViolationCollection Execute(DataTable candidate, DataTable reference)28 {29 var stopWatch = new Stopwatch();30 stopWatch.Start();31 var referenceKeyRetriever = BuildColumnsRetriever(Keys, x => x.ReferenceColumn);32 var referenceValueRetriever = BuildColumnsRetriever(Values, x => x.ReferenceColumn);33 var references = BuildReferenceIndex(reference, referenceKeyRetriever, referenceValueRetriever);34 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, $"Building the index (including value columns) for keys from the reference table containing {references.Count} rows [{stopWatch.Elapsed:d'.'hh':'mm':'ss'.'fff'ms'}]");35 stopWatch.Restart();36 var candidateKeyBuilder = BuildColumnsRetriever(Keys, x => x.CandidateColumn);37 var candidateValueRetriever = BuildColumnsRetriever(Values, x => x.CandidateColumn);38 var violations = ExtractLookupViolation(candidate, candidateKeyBuilder, candidateValueRetriever, references, Tolerances);39 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, $"Analyzing potential lookup violations (based on keys and values) for the {candidate.Rows.Count} rows from candidate table [{stopWatch.Elapsed:d'.'hh':'mm':'ss'.'fff'ms'}]");40 return violations;41 }42 protected IDictionary<KeyCollection, ICollection<KeyCollection>> BuildReferenceIndex(DataTable table, CellRetriever keyRetriever, CellRetriever valuesRetriever)43 {44 var references = new Dictionary<KeyCollection, ICollection<KeyCollection>>();45 foreach (DataRow row in table.Rows)46 {47 var keys = keyRetriever.GetColumns(row);48 var values = valuesRetriever.GetColumns(row);49 if (!references.ContainsKey(keys))50 references.Add(keys, new HashSet<KeyCollection>() { values });51 else...
LookupExistsAnalyzer.cs
Source:LookupExistsAnalyzer.cs
...28 protected virtual LookupViolationCollection Execute(DataTable candidate, DataTable reference)29 {30 var stopWatch = new Stopwatch();31 stopWatch.Start();32 var referenceKeyRetriever = BuildColumnsRetriever(Keys, x => x.ReferenceColumn);33 var references = BuildReferenceIndex(reference, referenceKeyRetriever);34 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, $"Building the index for keys from reference table containing {references.Count()} rows [{stopWatch.Elapsed:d'.'hh':'mm':'ss'.'fff'ms'}]");35 stopWatch.Restart();36 var candidateKeyBuilder = BuildColumnsRetriever(Keys, x => x.CandidateColumn);37 var violations = ExtractLookupViolation(candidate, candidateKeyBuilder, references);38 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, $"Analyzing potential lookup violations (based on keys) for the {candidate.Rows.Count} rows from candidate table [{stopWatch.Elapsed:d'.'hh':'mm':'ss'.'fff'ms'}]");39 return violations;40 }41 protected CellRetriever BuildColumnsRetriever(ColumnMappingCollection columns, Func<ColumnMapping, IColumnIdentifier> target)42 {43 var defColumns = new Collection<IColumnDefinition>();44 foreach (var column in columns)45 {46 var defColumn = column.ToColumnDefinition(() => target(column));47 defColumns.Add(defColumn);48 }49 if (columns.Any(x => target(x) is ColumnOrdinalIdentifier))50 return new CellRetrieverByOrdinal(defColumns);51 else52 return new CellRetrieverByName(defColumns);53 }54 protected IEnumerable<KeyCollection> BuildReferenceIndex(DataTable table, CellRetriever keyRetriever)55 {...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!