/// <summary> /// Summarises the test results by grouping by assembly and then by class. /// </summary> void SummariseByClass() { SummaryByClass = new TestResultSummary(); var sbaRows = ResultLines.GroupBy(r => new { r.AssemblyPathName, r.ClassName }) .Select(gr => new { AssemblyPathName = gr.Key.AssemblyPathName, FullClassName = gr.Key.ClassName, TestResults = gr }); foreach (var sbaRow in sbaRows) { var summary = new TestResultSummaryLine(); summary.AssemblyPathName = sbaRow.AssemblyPathName; summary.FullClassName = sbaRow.FullClassName; foreach (var ocn in OutcomeNames) { var oc = new ResultOutcomeSummary() { Outcome = ocn }; oc.NumTests = (from r in sbaRow.TestResults where r.Outcome == ocn select r).Count(); oc.TotalDurationInSeconds = (from r in sbaRow.TestResults where r.Outcome == ocn select r).Sum(r => r.DurationInSeconds); summary.Outcomes.Add(oc); } SummaryByClass.Add(summary); } }
int CreateSummary(string largeHeaderName, int rowNum, TestResultSummary summary, IEnumerable <string> outcomes) { int colNum = 0; int topOfSums = rowNum + 3; rowNum = CreateSummaryHeading(largeHeaderName, rowNum); IRow row = sheet.CreateRow(rowNum++); row.CreateHeadings(ColAssembly, "Assembly", "Class", "Time (secs)", "Time (hh:mm:ss)", "Pass Rate", "Total"); colNum = ColPassed; foreach (var oc in outcomes) { row.SetCell(colNum++, oc).HeaderStyle().ApplyStyle(); } foreach (var s in summary.SummaryLines.OrderBy(line => line.AssemblyFileName).ThenBy(line => line.ClassName)) { row = sheet.CreateRow(rowNum++); row.SetCell(ColAssembly, s.AssemblyFileName); row.SetCell(ColClass, s.ClassName); row.SetCell(ColTime, s.TotalDurationInSeconds).Format("0.00").ApplyStyle(); row.SetCell(ColTimeHuman, s.TotalDurationInSecondsHuman).Alignment(HorizontalAlignment.Right).ApplyStyle(); row.SetCell(ColPercent, s.PercentPassed).FormatPercentage().ApplyStyle(); row.SetCell(ColTotal, s.TotalTests); colNum = ColPassed; foreach (var oc in s.Outcomes) { var cell = row.SetCell(colNum++, oc.NumTests); if (oc.Outcome == KnownOutcomes.Failed && oc.NumTests > 0) { cell.SolidFillColor(HSSFColor.Red.Index).ApplyStyle(); } else if (oc.Outcome != KnownOutcomes.Passed && oc.NumTests > 0) { cell.SolidFillColor(HSSFColor.Yellow.Index).ApplyStyle(); } } } row = sheet.CreateRow(rowNum++); row.SetCell(ColTime, summary.TotalDurationInSeconds).SummaryStyle().Format("0.00").ApplyStyle(); row.SetCell(ColTimeHuman, summary.TotalDurationInSecondsHuman).SummaryStyle().Alignment(HorizontalAlignment.Right).ApplyStyle(); row.SetCell(ColPercent, summary.PercentPassed).SummaryStyle().FormatPercentage().ApplyStyle(); row.SetCell(ColTotal, summary.TotalTests).SummaryStyle().ApplyStyle(); int cn = ColPassed; foreach (var oc in outcomes) { row.SetCell(cn++, summary.TotalByOutcome(oc)).SummaryStyle().ApplyStyle(); } ApplyPercentageFormatting(ColPercent, topOfSums, rowNum - 1); ApplyFailedFormattingRules(topOfSums, rowNum - 1); return(rowNum); }
int CreateSummary(string largeHeaderName, int rowNum, TestResultSummary summary, IEnumerable<string> outcomes) { int colNum = 0; int topOfSums = rowNum + 3; rowNum = CreateSummaryHeading(largeHeaderName, rowNum); IRow row = sheet.CreateRow(rowNum++); row.CreateHeadings(ColAssembly, "Assembly", "Class", "Time (secs)", "Time (hh:mm:ss)", "Pass Rate", "Total"); colNum = ColPassed; foreach (var oc in outcomes) { row.SetCell(colNum++, oc).HeaderStyle().ApplyStyle(); } foreach (var s in summary.SummaryLines.OrderBy(line => line.AssemblyFileName).ThenBy(line => line.ClassName)) { row = sheet.CreateRow(rowNum++); row.SetCell(ColAssembly, s.AssemblyFileName); row.SetCell(ColClass, s.ClassName); row.SetCell(ColTime, s.TotalDurationInSeconds).Format("0.00").ApplyStyle(); row.SetCell(ColTimeHuman, s.TotalDurationInSecondsHuman).Alignment(HorizontalAlignment.Right).ApplyStyle(); row.SetCell(ColPercent, s.PercentPassed).FormatPercentage().ApplyStyle(); row.SetCell(ColTotal, s.TotalTests); colNum = ColPassed; foreach (var oc in s.Outcomes) { var cell = row.SetCell(colNum++, oc.NumTests); if (oc.Outcome == KnownOutcomes.Failed && oc.NumTests > 0) cell.SolidFillColor(HSSFColor.Red.Index).ApplyStyle(); else if (oc.Outcome != KnownOutcomes.Passed && oc.NumTests > 0) cell.SolidFillColor(HSSFColor.Yellow.Index).ApplyStyle(); } } row = sheet.CreateRow(rowNum++); row.SetCell(ColTime, summary.TotalDurationInSeconds).SummaryStyle().Format("0.00").ApplyStyle(); row.SetCell(ColTimeHuman, summary.TotalDurationInSecondsHuman).SummaryStyle().Alignment(HorizontalAlignment.Right).ApplyStyle(); row.SetCell(ColPercent, summary.PercentPassed).SummaryStyle().FormatPercentage().ApplyStyle(); row.SetCell(ColTotal, summary.TotalTests).SummaryStyle().ApplyStyle(); int cn = ColPassed; foreach (var oc in outcomes) { row.SetCell(cn++, summary.TotalByOutcome(oc)).SummaryStyle().ApplyStyle(); } ApplyPercentageFormatting(ColPercent, topOfSums, rowNum - 1); ApplyFailedFormattingRules(topOfSums, rowNum - 1); return rowNum; }