Example #1
0
        private MarkdownContainer BuildTable(TableHelper tableBuilder, IEnumerable <DataRow> rows, string title, ISampler <DataRow> sampler)
        {
            rows = rows ?? new List <DataRow>();

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

            var container = new MarkdownContainer();

            if (!String.IsNullOrEmpty(title))
            {
                var titleText = string.Format($"{title} rows:");
                container.Append(titleText.ToMarkdownSubHeader());
            }

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

            if (sampler.GetIsSampled())
            {
                var rowsSkipped = string.Format($"{sampler.GetExcludedRowCount()} (of {rows.Count()}) rows have been skipped for display purpose.");
                container.Append(rowsSkipped.ToMarkdownParagraph());
            }

            return(container);
        }
        private MarkdownContainer BuildTable(TableHelper tableBuilder, IEnumerable <DataRow> rows, string title, FailureReportSetType sampling)
        {
            rows = rows ?? new List <DataRow>();

            var table = tableBuilder.Build(Sample(rows, sampling));

            var container = new MarkdownContainer();

            if (!String.IsNullOrEmpty(title))
            {
                var titleText = string.Format("{0} rows:", title);
                container.Append(titleText.ToMarkdownSubHeader());
            }

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

            if (IsSampled(rows, sampling))
            {
                var rowsSkipped = string.Format("{0} (of {1}) rows have been skipped for display purpose.", CountExcludedRows(rows), rows.Count());
                container.Append(rowsSkipped.ToMarkdownParagraph());
            }

            return(container);
        }
 public void BuildDuplication(IEnumerable <DataRow> actualRows, DuplicatedRowsResult result)
 {
     actual = new MarkdownContainer();
     actual.Append(new Paragraph($"The actual result-set has {result.RowCount} rows and contains {result.Values.Count()} unique rows duplicated."));
     actual.Append(BuildTable(style, actualRows, Profile.ActualSet));
     duplicated = new MarkdownContainer();
     duplicated.Append(BuildNonEmptyTable(style, result.Rows, "Duplicated", Profile.AnalysisSet));
 }
Example #4
0
        private MarkdownContainer BuildList(IEnumerable <string> items, string title, FailureReportSetType sampling)
        {
            var container = new MarkdownContainer();

            container.Append((title + " items:").ToMarkdownSubHeader());
            container.Append(BuildList(items, sampling));

            return(container);
        }
Example #5
0
        private MarkdownContainer BuildList(IEnumerable <string> items, string title, ISampler <string> sampler)
        {
            var container = new MarkdownContainer();

            container.Append((title + " items:").ToMarkdownSubHeader());
            container.Append(BuildList(items, sampler));

            return(container);
        }
Example #6
0
        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"]));
        }
Example #7
0
        public void BuildDuplication(IEnumerable <DataRow> actualRows, ResultUniqueRows result)
        {
            actual = new MarkdownContainer();
            var sb          = new StringBuilder();
            var uniqueCount = actualRows.Count() - result.Rows.Sum(x => Convert.ToInt32(x[0]));

            sb.Append($"The actual result-set has {result.RowCount} rows.");
            sb.Append($" {uniqueCount} row{(uniqueCount > 1 ? "s are" : " is")} effectively unique");
            sb.Append($" and {result.Values.Count()} distinct row{(result.Values.Count() > 1 ? "s are" : " is")} duplicated.");
            actual.Append(new Paragraph(sb.ToString()));
            actual.Append(BuildTable(style, actualRows, samplers["actual"]));
            analysis = new MarkdownContainer();
            analysis.Append(BuildNonEmptyTable(style, result.Rows, "Duplicated", samplers["analysis"]));
        }
Example #8
0
        public MarkdownContainer Build(IEnumerable <DataRow> dataRows)
        {
            var container = new MarkdownContainer();

            if (dataRows.Count() == 0)
            {
                container.Append(BuildEmptyTable());
            }
            else
            {
                container.Append(BuildNonEmptyTable(dataRows));
            }

            return(container);
        }
Example #9
0
        public void ContainerExample()
        {
            var log = new MarkdownContainer();

            var countries = new[] { "Zimbabwe", "Italy", "Bolivia", "Finland", "Australia" };

            log.Append("Countries (unsorted)".ToMarkdownHeader());
            log.Append(countries.ToMarkdownNumberedList());

            var sorted = countries.OrderBy(i => i);

            log.Append("Countries (sorted)".ToMarkdownHeader());
            log.Append(sorted.ToMarkdownNumberedList());

            Console.Write(log);
        }
Example #10
0
        protected virtual void RenderNonEmptyTable(IEnumerable <T> rows, IEnumerable <ColumnMetadata> metadatas, ISampler <T> sampler, MarkdownContainer container)
        {
            var extendedDefinitions = BuildExtendedMetadatas(rows.ElementAt(0), metadatas);

            container.Append($"Result-set with {rows.Count()} row{(rows.Count() > 1 ? "s" : string.Empty)}".ToMarkdownParagraph());
            container.Append(new TableExtended()
            {
                Columns = RenderColumns(extendedDefinitions), Rows = RenderRows(Sampler.GetResult(), extendedDefinitions)
            });

            if (Sampler.GetIsSampled())
            {
                var rowsSkipped = $"{Sampler.GetExcludedRowCount()} (of {Rows.Count()}) rows have been skipped for display purpose.";
                container.Append(rowsSkipped.ToMarkdownParagraph());
            }
        }
Example #11
0
        protected override void RenderAnalysis(LookupViolationCollection violations, IEnumerable <ColumnMetadata> metadata, ISampler <DataRow> sampler, ColumnMappingCollection keyMappings, ColumnMappingCollection valueMappings, MarkdownContainer container)
        {
            container.Append("Analysis".ToMarkdownHeader());
            var state = violations.Values.Select(x => x.State).First();

            container.Append(GetExplanationText(violations, state).ToMarkdownParagraph());

            var rows = violations.Values.Where(x => x is LookupExistsViolationInformation)
                       .Cast <LookupExistsViolationInformation>()
                       .SelectMany(x => x.CandidateRows);

            sampler.Build(rows);

            var tableHelper = new StandardTableHelperMarkdown(rows, metadata, sampler);

            tableHelper.Render(container);
        }
Example #12
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);
        }
Example #13
0
        public void Build(IEnumerable <string> expectedItems, IEnumerable <string> actualItems, ListComparer.Result result)
        {
            expectedItems = expectedItems ?? new List <string>();
            actualItems   = actualItems ?? new List <string>();
            result        = result ?? new ListComparer.Result(null, null);

            expected = BuildList(expectedItems, samplers["expected"]);
            actual   = BuildList(actualItems, samplers["actual"]);
            analysis = BuildIfNotEmptyList(result.Missing ?? new List <string>(), "Missing", samplers["analysis"]);
            analysis.Append(BuildIfNotEmptyList(result.Unexpected ?? new List <string>(), "Unexpected", samplers["analysis"]));
        }
Example #14
0
        private MarkdownContainer BuildList(IEnumerable <string> items, FailureReportSetType sampling)
        {
            var sampledItems = Sample(items, sampling).ToList();

            var container = new MarkdownContainer();

            if (items.Count() > 0)
            {
                container.Append(string.Format("Set of {0} item{1}", items.Count(), items.Count() > 1 ? "s" : string.Empty).ToMarkdownParagraph());
                container.Append(sampledItems.ToMarkdownBulletedList());
            }
            else
            {
                container.Append("An empty set.".ToMarkdownParagraph());
            }

            if (IsSampled(items, sampling))
            {
                container.Append(string.Format("... and {0} others not displayed.", CountExcludedRows(items)).ToMarkdownParagraph());
            }

            return(container);
        }
Example #15
0
        private MarkdownContainer BuildList(IEnumerable <string> items, ISampler <string> sampler)
        {
            sampler.Build(items);
            var sampledItems = sampler.GetResult();

            var container = new MarkdownContainer();

            if (items.Count() > 0)
            {
                container.Append($"Set of {items.Count()} item{(items.Count() > 1 ? "s" : string.Empty)}".ToMarkdownParagraph());
                container.Append(sampledItems.ToMarkdownBulletedList());
            }
            else
            {
                container.Append("An empty set.".ToMarkdownParagraph());
            }

            if (sampler.GetIsSampled())
            {
                container.Append($"... and {sampler.GetExcludedRowCount()} others not displayed.".ToMarkdownParagraph());
            }

            return(container);
        }
Example #16
0
        public void TestCanConfigureOutputOfCollectionsUsingExtensionMethod()
        {
            var bart = new Person {
                Name = "Bart Simpson", Age = 10
            };
            var lisa = new Person {
                Name = "Lisa Simpson", Age = 8
            };
            var maggie = new Person {
                Name = "Maggie Simpson", Age = 1
            };
            var homer = new Person {
                Name = "Homer Simpson", Age = 36, Children = new[] { bart, lisa, maggie }
            };
            var marge = new Person {
                Name = "Marge Simpson", Age = 35, Children = new[] { bart, lisa, maggie }
            };
            var milhouse = new Person {
                Name = "Milhouse Van Houten ", Age = 10
            };

            var simpsons = new[] { homer, marge, bart, lisa, maggie, milhouse };

            var md = new MarkdownContainer();

            md.Append("Table built with no options".ToMarkdownHeader());
            md.Append(simpsons.ToMarkdownTable());

            md.Append("Table built with Default options".ToMarkdownHeader());
            md.Append(simpsons.ToMarkdownTable(TableOptions.Default));

            md.Append("Table built with ExcludeCollectionProperties options".ToMarkdownHeader());
            md.Append(simpsons.ToMarkdownTable(TableOptions.ExcludeCollectionProperties));

            Console.WriteLine(md);
        }
Example #17
0
 protected virtual void RenderEmptyTable(MarkdownContainer container)
 => container.Append("This result-set is empty.".ToMarkdownParagraph());