Пример #1
0
        /// <summary>
        /// Creates the summary report.
        /// </summary>
        /// <param name="summaryResult">The summary result.</param>
        public void CreateSummaryReport(SummaryResult summaryResult)
        {
            if (summaryResult == null)
            {
                throw new ArgumentNullException(nameof(summaryResult));
            }

            var historicCoverages = this.GetOverallHistoricCoverages(this.ReportContext.OverallHistoricCoverages);

            var filteredHistoricCoverages = this.FilterHistoricCoverages(historicCoverages, 100);

            if (filteredHistoricCoverages.Any(h => h.CoverageQuota.HasValue || h.BranchCoverageQuota.HasValue))
            {
                byte[] image = PngHistoryChartRenderer.RenderHistoryChart(filteredHistoricCoverages);
                File.WriteAllBytes(Path.Combine(this.ReportContext.ReportConfiguration.TargetDirectory, "CoverageHistory.png"), image);
            }
        }
Пример #2
0
        /// <summary>
        /// Creates the summary report.
        /// </summary>
        /// <param name="summaryResult">The summary result.</param>
        public void CreateSummaryReport(SummaryResult summaryResult)
        {
            if (summaryResult == null)
            {
                throw new ArgumentNullException(nameof(summaryResult));
            }

            var historicCoverages = this.GetOverallHistoricCoverages(this.ReportContext.OverallHistoricCoverages);

            var filteredHistoricCoverages = this.FilterHistoricCoverages(historicCoverages, 100);

            if (filteredHistoricCoverages.Any(h => h.CoverageQuota.HasValue || h.BranchCoverageQuota.HasValue))
            {
                byte[] image = PngHistoryChartRenderer.RenderHistoryChart(filteredHistoricCoverages);

                string targetDirectory = this.ReportContext.ReportConfiguration.TargetDirectory;

                if (this.ReportContext.Settings.CreateSubdirectoryForAllReportTypes)
                {
                    targetDirectory = Path.Combine(targetDirectory, this.ReportType);

                    if (!Directory.Exists(targetDirectory))
                    {
                        try
                        {
                            Directory.CreateDirectory(targetDirectory);
                        }
                        catch (Exception ex)
                        {
                            Logger.ErrorFormat(Resources.TargetDirectoryCouldNotBeCreated, targetDirectory, ex.GetExceptionMessageForDisplay());
                            return;
                        }
                    }
                }

                string targetPath = Path.Combine(targetDirectory, "CoverageHistory.png");

                Logger.InfoFormat(Resources.WritingReportFile, targetPath);

                File.WriteAllBytes(targetPath, image);
            }
        }