/// <summary>
        /// Populates the SummaryReport template.
        /// </summary>
        /// <param name="templateData"></param>
        private static void WriteSummaryReport(SummaryReportSharedData templateData)
        {
            var htmlWriterForSummaryReport = new HtmlTextWriter(new StreamWriter(SUMMARY_FILENAME));

            var template = new SummaryReport();

            template.Session = new Dictionary <string, object>()
            {
                { "SharedDataObject", templateData }
            };

            template.Initialize();
            htmlWriterForSummaryReport.WriteLine(template.TransformText());
            htmlWriterForSummaryReport.Close();

            htmlWriterForSummaryReport.Dispose();
            htmlWriterForSummaryReport = null;
        }
        /// <summary>
        /// Computes the gathered data together for the home page.
        /// </summary>
        /// <param name="duration"></param>
        /// <param name="errorHappened"></param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        private SummaryReportSharedData ComputeSummaryStatistics(TimeSpan duration, string errorHappened, string errorMessage)
        {
            int      countTroubleFreeOldIds      = 0;
            TimeSpan averageDurationPerOldId     = TimeSpan.Zero;
            var      countByDataBehavior         = new Dictionary <EnumIdentifiedDataBehavior, int>();
            var      averageDuration_ByTestName  = new Dictionary <EnumTestUnitNames, TimeSpan>();
            var      frequencySuccess_ByTestName = new Dictionary <EnumTestUnitNames, double>();
            double   countSuccessResults         = 0;
            var      missingResults = new HashSet <EnumTestUnitNames>();

            var countSeverityResults = new Dictionary <EnumResultSeverityType, int>();

            foreach (var severity in (EnumResultSeverityType[])Enum.GetValues(typeof(EnumResultSeverityType)))
            {
                countSeverityResults.Add(severity, 0);
            }


            foreach (var OldIdPair in NoWarningNorErrorHappenedFlag_ByOldId)
            {
                if (OldIdPair.Value == false)
                {
                    countTroubleFreeOldIds++;
                }
            }

            // make sure no division by zero
            if (StatsCountTotalOldIds > 0)
            {
                // deduce ignored profiles from statistics, to still reach 100%
                this.StatsCountTotalOldIds -= this.StatsCountProfilesIgnored;

                foreach (var testName in AllTestNames)
                {
                    countSuccessResults = 0;

                    foreach (var countSeverityResultsPair in countSeverityTypeOccurences[testName])
                    {
                        switch (countSeverityResultsPair.Key)
                        {
                        case EnumResultSeverityType.SUCCESS:
                        case EnumResultSeverityType.WARNING_NO_DATA:
                        case EnumResultSeverityType.WARNING_ONLY_NEW:
                        case EnumResultSeverityType.WARNING:
                        case EnumResultSeverityType.FALSE_POSITIVE:
                            // define overall success % for given test
                            countSuccessResults += countSeverityResultsPair.Value;
                            break;
                        }

                        // add count of results to the overall total by severity, without considering the test name
                        countSeverityResults[countSeverityResultsPair.Key] += countSeverityResultsPair.Value;
                    }

                    if (countSeverityTypeOccurences[testName].Values.Sum() < this.StatsCountTotalOldIds)
                    {
                        missingResults.Add(testName);
                    }

                    frequencySuccess_ByTestName.Add(testName, countSuccessResults / this.StatsCountTotalOldIds);

                    foreach (var countDataBehaviorPair in countDataBehaviorOccurences[testName])
                    {
                        if (!countByDataBehavior.ContainsKey(countDataBehaviorPair.Key))
                        {
                            countByDataBehavior.Add(countDataBehaviorPair.Key, 0);
                        }
                        countByDataBehavior[countDataBehaviorPair.Key] += countDataBehaviorPair.Value;
                    }

                    countDataBehaviorOccurences[testName].OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

                    averageDuration_ByTestName.Add(testName, TimeSpan.FromMilliseconds(durations[testName].Average(t => t.TotalMilliseconds) / this.StatsCountTotalOldIds));
                }

                averageDurationPerOldId = TimeSpan.FromMilliseconds(durationByProfile.Average(t => t.TotalMilliseconds) / this.StatsCountTotalOldIds);
            }

            var summaryReportData = new SummaryReportSharedData
            {
                StartTime                             = DateTime.Now,
                Not100PercentReturned                 = missingResults,
                CountProfilesTested                   = StatsCountTotalOldIds,
                CountProfilesWithoutWarnings          = countTroubleFreeOldIds,
                CountBySeverity                       = countSeverityResults.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value),
                CountByIdentifiedDataBehavior         = countByDataBehavior.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value),
                AllTestNames                          = countSeverityTypeOccurences.Keys.ToList(),
                CountSeverityByTestName               = countSeverityTypeOccurences,
                CountIdentifiedDataBehaviorByTestName = countDataBehaviorOccurences,
                CountTestsRun                         = StatsCountTotalOldIds * countSeverityResults.Keys.Count(),
                CountTestsPerUser                     = AllTestNames.Count(),
                FrequencySuccessByTestName            = frequencySuccess_ByTestName.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value),
                SampleDataByTestName                  = sampleDataByTestName,
                Duration                  = duration,
                LinkEnd2TestNameFile      = "_" + countFilesGenerated + HTM_EXTENSION,
                AverageDurationPerProfile = averageDurationPerOldId,
                AverageDurationByTestName = averageDuration_ByTestName,
                ErrorHappened             = errorHappened,
                ErrorMessage              = errorMessage,
                Link2ProfileFile          = SUMMARY_BY_PROFILE_FILENAME,
                CountProfilesIgnored      = this.StatsCountProfilesIgnored
            };

            return(summaryReportData);
        }