public void RenderCompared_WithSpecialRows_DisplayTextForThisKindOfRows( int missingRowCount , int unexpectedRowCount , int duplicatedRowCount , int keyMatchingRowCount , int nonMatchingValueRowCount , string expectedText) { var compared = ResultResultSet.Build( GetDataRows(missingRowCount) , GetDataRows(unexpectedRowCount) , GetDataRows(duplicatedRowCount) , GetDataRows(keyMatchingRowCount) , GetDataRows(nonMatchingValueRowCount) ); var samplers = new SamplersFactory<DataRow>().Instantiate(FailureReportProfile.Default); var msg = new DataRowsMessageJson(EngineStyle.ByIndex, samplers); msg.BuildComparaison(null, null, compared); var value = msg.RenderAnalysis(); Assert.That(value, Is.StringContaining($"\"{expectedText}\":{{\"total-rows\":3")); Assert.That(value, Is.Not.StringContaining($"\"{expectedText}\":{{\"total-rows\":3}}}}")); }
protected ResultResultSet doCompare(DataRow x, DataRow y) { var chrono = DateTime.Now; var missingRows = new List <DataRow>(); var unexpectedRows = new List <DataRow>(); if (x == null && y != null) { unexpectedRows.Add(y); } if (x != null && y == null) { missingRows.Add(x); } Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, string.Format("Analyzing length of result-sets: [{0}]", DateTime.Now.Subtract(chrono).ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s"))); IList <DataRow> nonMatchingValueRows = new List <DataRow>(); if (missingRows.Count == 0 && unexpectedRows.Count == 0) { chrono = DateTime.Now; var columnsCount = Math.Max(y.Table.Columns.Count, x.Table.Columns.Count); if (Settings == null) { BuildDefaultSettings(columnsCount); } else { Settings.ApplyTo(columnsCount); } PreliminaryChecks(x.Table, y.Table); Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, string.Format("Analyzing length and format of result-sets: [{0}]", DateTime.Now.Subtract(chrono).ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s"))); // If all of the columns make up the key, then we already know which rows match and which don't. // So there is no need to continue testing chrono = DateTime.Now; var nonMatchingValueRow = CompareRows(x, y); if (nonMatchingValueRow != null) { nonMatchingValueRows.Add(nonMatchingValueRow); } Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, string.Format("Rows with a matching key but without matching value: {0} [{1}]", nonMatchingValueRows.Count(), DateTime.Now.Subtract(chrono).ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s"))); } return(ResultResultSet.Build( missingRows, unexpectedRows, new List <DataRow>(), new List <DataRow>(), nonMatchingValueRows )); }
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 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(expectedRows, samplers["expected"]); actual = BuildTable(actualRows, samplers["actual"]); analysis = BuildMultipleTables( new[] { new Tuple <string, IEnumerable <DataRow>, TableHelperJson>("unexpected", compareResult.Unexpected, new TableHelperJson()), new Tuple <string, IEnumerable <DataRow>, TableHelperJson>("missing", compareResult.Missing, new TableHelperJson()), new Tuple <string, IEnumerable <DataRow>, TableHelperJson>("duplicated", compareResult.Duplicated, new TableHelperJson()), new Tuple <string, IEnumerable <DataRow>, TableHelperJson>("non-matching", compareResult.NonMatchingValue.Rows, new CompareTableHelperJson()), }, samplers["analysis"] ); }
protected virtual ResultResultSet doCompare(DataTable x, DataTable y) { var stopWatch = new Stopwatch(); var columnsCount = Math.Max(y.Columns.Count, x.Columns.Count); PreliminaryChecks(x, y); var keyComparer = BuildDataRowsKeyComparer(x); stopWatch.Start(); BuildRowDictionary(x, xDict, keyComparer, false); Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, string.Format("Building first rows dictionary: {0} [{1}]", x.Rows.Count, stopWatch.Elapsed.ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s"))); stopWatch.Reset(); stopWatch.Start(); BuildRowDictionary(y, yDict, keyComparer, true); Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, string.Format("Building second rows dictionary: {0} [{1}]", y.Rows.Count, stopWatch.Elapsed.ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s"))); stopWatch.Reset(); var missingRowsAnalyzer = analyzers.FirstOrDefault(a => a.GetType() == typeof(MissingRowsAnalyzer)); var missingRows = missingRowsAnalyzer?.Retrieve(xDict, yDict) ?? new List <RowHelper>(); var unexpectedRowsAnalyzer = analyzers.FirstOrDefault(a => a.GetType() == typeof(UnexpectedRowsAnalyzer)); var unexpectedRows = unexpectedRowsAnalyzer?.Retrieve(xDict, yDict) ?? new List <RowHelper>(); var keyMatchingRowsAnalyzer = analyzers.FirstOrDefault(a => a.GetType() == typeof(KeyMatchingRowsAnalyzer)); var keyMatchingRows = keyMatchingRowsAnalyzer?.Retrieve(xDict, yDict) ?? new List <RowHelper>(); stopWatch.Start(); var nonMatchingValueRows = !CanSkipValueComparison() ? CompareSets(keyMatchingRows) : new List <DataRow>(); Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, string.Format("Rows with a matching key but without matching value: {0} [{1}]", nonMatchingValueRows.Count(), stopWatch.Elapsed.ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s"))); stopWatch.Reset(); var duplicatedRows = new List <DataRow>(); // Dummy placeholder return(ResultResultSet.Build( missingRows.Select(a => a.DataRowObj).ToList(), unexpectedRows.Select(a => a.DataRowObj).ToList(), duplicatedRows, keyMatchingRows.Select(a => a.DataRowObj).ToList(), nonMatchingValueRows )); }
protected bool doMatch(ResultSet actual) { actualResultSet = actual; //This is needed if we don't use //ism if (expectedResultSet == null) { expectedResultSet = expect.Execute(); } result = Engine.Compare(actualResultSet, expectedResultSet); var output = result.Difference == ResultSetDifferenceType.None; if (output && Configuration?.FailureReportProfile.Mode == FailureReportMode.Always) { Assert.Pass(Failure.RenderMessage()); } return(output); }