Пример #1
0
        internal static SortedDictionary <string, AreaSummaryEntry> ProduceAreaSummaries(TestRecords tests)
        {
            SortedDictionary <string, AreaSummaryEntry> SummaryTable = new SortedDictionary <string, AreaSummaryEntry>(StringComparer.OrdinalIgnoreCase);

            //Go through VariationRecords in each test to build up SummaryStats
            foreach (TestRecord test in tests.TestCollection)
            {
                AreaSummaryEntry entry;
                string           area = test.TestInfo.Area;

                //Create Entry if area doesn't exist yet, else load it up
                if (!SummaryTable.ContainsKey(area))
                {
                    entry = new AreaSummaryEntry();
                    entry.TestExecutionTime = new TimeSpan();
                    entry.Name            = area;
                    entry.AssociatedTests = new TestCollection();
                    SummaryTable.Add(area, entry);
                }
                else
                {
                    entry = SummaryTable[area];
                }
                entry.AssociatedTests.Add(test);
                bool hasBugs = (test.TestInfo.Bugs != null && test.TestInfo.Bugs.Count > 0);
                foreach (VariationRecord variation in test.Variations)
                {
                    entry.TotalVariations          += ReportingUtilities.OneForCountable(variation.Result);
                    entry.FailedVariations         += ReportingUtilities.OneForFail(variation.Result);
                    entry.IgnoredVariations        += ReportingUtilities.OneForIgnore(variation.Result);
                    entry.FailedVariationsWithBugs += ReportingUtilities.OneForFailOnBug(variation.Result, hasBugs);
                }
                entry.TestExecutionTime += test.Duration;
            }

            foreach (ExecutionGroupRecord group in tests.ExecutionGroupRecords)
            {
                AreaSummaryEntry entry;
                string           area = group.Area;
                //Assumption - all areas have been defined by the list of tests scanned in above loop
                entry = SummaryTable[area];

                entry.TotalExecutionTime += ReportingUtilities.GetGroupDuration(group);
                // Take the earliest start time as the start of the entire area
                if (entry.StartTime < group.StartTime.DateTime)
                {
                    entry.StartTime = group.StartTime.DateTime;
                }

                // Take the last end time as the end of the entire area
                if (group.EndTime.DateTime > entry.EndTime)
                {
                    entry.EndTime = group.EndTime.DateTime;
                }
            }

            return(SummaryTable);
        }