private MarkdownContainer BuildMultipleTable(LookupViolations violations, string title, ISampler <KeyCollection> keyCollectionSampler, ISampler <DataRow> dataRowSampler)
        {
            var tableBuilder = new TableHelper(EngineStyle.ByIndex);
            var container    = new MarkdownContainer();

            keyCollectionSampler.Build(violations.Keys);
            container.Append($"{violations.Keys.Count} missing reference{(violations.Keys.Count>1 ? "s" : string.Empty)}".ToMarkdownHeader());
            if (keyCollectionSampler.GetIsSampled())
            {
                container.Append($"{keyCollectionSampler.GetExcludedRowCount()} (of {violations.Keys.Count}) rows have been skipped for display purpose.".ToMarkdownParagraph());
            }

            foreach (var keyCollection in keyCollectionSampler.GetResult())
            {
                var rows = violations[keyCollection];
                container.Append($"Following reference is missing ({rows.Count} occurence{(rows.Count > 1 ? "s" : string.Empty)}):".ToMarkdownParagraph());
                container.Append(new BulletedList(keyCollection.Members.Cast <string>()));

                dataRowSampler.Build(rows);
                var table = tableBuilder.Build(dataRowSampler.GetResult());

                container.Append(BuildRowCount(rows.Count()));
                container.Append(table);

                if (dataRowSampler.GetIsSampled())
                {
                    var rowsSkipped = $"{dataRowSampler.GetExcludedRowCount()} (of {rows.Count()}) rows have been skipped for display purpose.";
                    container.Append(rowsSkipped.ToMarkdownParagraph());
                }
            }
            return(container);
        }
示例#2
0
        protected virtual bool doMatch(ResultSet actual)
        {
            violations = Engine.Execute(actual, rsReference);
            var output = violations.Count == 0;

            if (output && Configuration?.FailureReportProfile.Mode == FailureReportMode.Always)
            {
                Assert.Pass(Failure.RenderMessage());
            }

            return(output);
        }
示例#3
0
        private LookupViolations ExtractReferenceViolation(DataTable table, KeysRetriever keyRetriever, IEnumerable <KeyCollection> references)
        {
            var violations = new LookupViolations();

            foreach (DataRow row in table.Rows)
            {
                var keys = keyRetriever.GetKeys(row);
                if (!references.Contains(keys))
                {
                    if (violations.ContainsKey(keys))
                    {
                        violations[keys].Add(row);
                    }
                    else
                    {
                        violations.Add(keys, new Collection <DataRow>()
                        {
                            row
                        });
                    }
                }
            }
            return(violations);
        }
 public void Generate(IEnumerable <DataRow> parentRows, IEnumerable <DataRow> childRows, LookupViolations violations)
 {
     parent   = BuildTable(parentRows, dataRowsSamplers["expected"]);
     child    = BuildTable(childRows, dataRowsSamplers["actual"]);
     analysis = BuildMultipleTable(violations, "Missing references", keysCollectionSamplers["analysis"], dataRowsSamplers["analysis"]);
 }
        public void Generate(IEnumerable <DataRow> parentRows, IEnumerable <DataRow> childRows, LookupViolations violations)
        {
            expected = BuildTable(parentRows, samplers["expected"]);
            actual   = BuildTable(childRows, samplers["actual"]);

            var rows = new List <DataRow>();

            foreach (var violation in violations)
            {
                rows = rows.Union(violation.Value).ToList();
            }

            analysis = BuildMultipleTables(
                new[]
            {
                new Tuple <string, IEnumerable <DataRow>, TableHelperJson>("missing", rows, new CompareTableHelperJson()),
            }, samplers["analysis"]
                );
        }