Пример #1
0
        private static List <HtmlReportDataQualityCategory> GroupByCategories(
            [NotNull] IEnumerable <IssueGroup> issueGroups,
            [CanBeNull] IHtmlDataQualityCategoryOptionsProvider optionsProvider,
            [NotNull] out List <HtmlReportIssueGroup> reportIssueGroups)
        {
            var statistics = new IssueStatistics(issueGroups);

            return(HtmlReportUtils.GroupByCategories(
                       statistics,
                       new HtmlReportDataQualityCategoryComparer(),
                       new HtmlReportQualityConditionComparer(),
                       new HtmlReportIssueGroupComparer(),
                       ig => "testidentifier",
                       optionsProvider,
                       out reportIssueGroups));
        }
Пример #2
0
        public void CanAggregateExceptionCategoryCounts()
        {
            var exceptionCategories = new List <ExceptionCategory>
            {
                new ExceptionCategory("C"),
                new ExceptionCategory("B"),
                new ExceptionCategory("A"),
                new ExceptionCategory(null)
            };

            var categoryCounts = new List <HtmlExceptionCategoryCount>();

            categoryCounts.Add(new HtmlExceptionCategoryCount(new ExceptionCategory("b"), 10));
            categoryCounts.Add(
                new HtmlExceptionCategoryCount(new ExceptionCategory(null), 100));

            List <HtmlExceptionCategoryCount> result =
                HtmlReportUtils.AggregateExceptionCategoryCounts(
                    categoryCounts, exceptionCategories);

            foreach (HtmlExceptionCategoryCount aggregated in result)
            {
                Console.WriteLine($@"{aggregated.Name}: {aggregated.ExceptionCount}");
            }

            Assert.AreEqual(4, result.Count);

            Assert.AreEqual("C", result[0].Name);
            Assert.AreEqual(0, result[0].ExceptionCount);

            Assert.AreEqual("B", result[1].Name);
            Assert.AreEqual(10, result[1].ExceptionCount);

            Assert.AreEqual("A", result[2].Name);
            Assert.AreEqual(0, result[2].ExceptionCount);

            Assert.AreEqual("-", result[3].Name);
            Assert.AreEqual(100, result[3].ExceptionCount);
        }
Пример #3
0
        public HtmlReportModel(
            [NotNull] QualitySpecification qualitySpecification,
            [NotNull] IIssueStatistics statistics,
            [NotNull] XmlVerificationReport verificationReport,
            [NotNull] string outputDirectoryPath,
            [NotNull] string verificationReportName,
            [CanBeNull] string issueGeodatabasePath,
            [CanBeNull] IEnumerable <string> issueMapFilePaths,
            [NotNull] IEnumerable <string> htmlReportFileNames,
            [CanBeNull] IEnumerable <string> qualitySpecificationReportFilePaths,
            [NotNull] IHtmlDataQualityCategoryOptionsProvider categoryOptionsProvider)
        {
            Assert.ArgumentNotNull(qualitySpecification, nameof(qualitySpecification));
            Assert.ArgumentNotNull(statistics, nameof(statistics));
            Assert.ArgumentNotNull(verificationReport, nameof(verificationReport));
            Assert.ArgumentNotNullOrEmpty(outputDirectoryPath, nameof(outputDirectoryPath));
            Assert.ArgumentNotNullOrEmpty(verificationReportName,
                                          nameof(verificationReportName));
            Assert.ArgumentNotNull(categoryOptionsProvider, nameof(categoryOptionsProvider));

            _verificationReport = verificationReport;
            HtmlReportFiles     =
                htmlReportFileNames.Select(
                    fileName =>
                    new OutputFile(
                        Path.Combine(outputDirectoryPath, fileName)))
                .ToList();
            IssueMapFiles = issueMapFilePaths?.Select(path => new OutputFile(path))
                            .ToList() ?? new List <OutputFile>();
            QualitySpecificationReportFiles =
                qualitySpecificationReportFilePaths?.Select(path => new OutputFile(path))
                .ToList() ?? new List <OutputFile>();

            Properties               = new NameValuePairs(GetProperties(verificationReport.Properties));
            QualitySpecification     = qualitySpecification.Name;
            VerificationWasCancelled = verificationReport.Cancelled;
            HasVerificationExtent    = verificationReport.TestExtent != null;

            if (verificationReport.TestExtent != null)
            {
                VerificationExtentString = HtmlReportUtils.FormatExtent(
                    verificationReport.TestExtent);
            }

            if (verificationReport.AreaOfInterest != null)
            {
                AreaOfInterest = HtmlReportUtils.GetAreaOfInterest(
                    verificationReport.AreaOfInterest);
            }

            OutputDirectoryPath        = outputDirectoryPath;
            OutputDirectoryName        = Assert.NotNull(Path.GetFileName(outputDirectoryPath));
            OutputDirectoryRelativeUrl = HtmlReportUtils.GetRelativeUrl(string.Empty);
            OutputDirectoryAbsoluteUrl = outputDirectoryPath;

            VerificationReportName = verificationReportName;
            VerificationReportUrl  = HtmlReportUtils.GetRelativeUrl(verificationReportName);

            if (IssueMapFiles.Count > 0)
            {
                OutputFile issueMapFile = IssueMapFiles[0];

                MapDocumentName = issueMapFile.FileName;
                MapDocumentUrl  = issueMapFile.Url;
            }

            IssueGeodatabaseName = Path.GetFileName(issueGeodatabasePath);

            List <HtmlReportDataQualityCategory> categories =
                HtmlReportUtils.GroupByCategories(
                    statistics,
                    new HtmlReportDataQualityCategoryComparer(),
                    new HtmlReportQualityConditionComparer(),
                    new HtmlReportIssueGroupComparer(),
                    GetTestIdentifier,
                    categoryOptionsProvider,
                    out _issueGroups);

            CategoriesWithIssues = categories.Where(c => c.IssueGroups.Count > 0).ToList();
            RootCategories       = categories.Where(c => c.IsRoot).ToList();

            HasWarnings = statistics.WarningCount > 0;
            HasErrors   = statistics.ErrorCount > 0;
            HasIssues   = !HasWarnings && !HasErrors;

            IssueCount = HtmlReportUtils.Format(statistics.WarningCount +
                                                statistics.ErrorCount);
            WarningCount   = HtmlReportUtils.Format(statistics.WarningCount);
            ErrorCount     = HtmlReportUtils.Format(statistics.ErrorCount);
            ExceptionCount = HtmlReportUtils.Format(statistics.ExceptionCount);

            TimeSpan t = TimeSpan.FromSeconds(verificationReport.ProcessingTimeSeconds);

            ProcessingTime = HtmlReportUtils.FormatTimeSpan(t);
        }