예제 #1
0
        private MarkdownContainer BuildMultipleTable(ReferenceViolations 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 bool doMatch(ResultSet actual)
        {
            violations = Engine.Execute(actual, rsParent);
            var output = violations.Count == 0;

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

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

            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);
        }
예제 #4
0
        public void Generate(IEnumerable <DataRow> parentRows, IEnumerable <DataRow> childRows, ReferenceViolations 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"]
                );
        }
예제 #5
0
 public void Generate(IEnumerable <DataRow> parentRows, IEnumerable <DataRow> childRows, ReferenceViolations violations)
 {
     parent   = BuildTable(parentRows, dataRowsSamplers["expected"]);
     child    = BuildTable(childRows, dataRowsSamplers["actual"]);
     analysis = BuildMultipleTable(violations, "Missing references", keysCollectionSamplers["analysis"], dataRowsSamplers["analysis"]);
 }