private static string CreateTestResultHtml(IReport report) { var hasPassed = true; foreach (var section in report.Sections().SelectMany(s => s.Sections())) { hasPassed = hasPassed && section.WasSuccessful; if (!hasPassed) { break; } } var template = hasPassed ? @"Sherlock.Shared.Core.Reporting.Templates.ReportResultPassedTemplate.html" : @"Sherlock.Shared.Core.Reporting.Templates.ReportResultFailedTemplate.html"; return EmbeddedResourceExtracter.LoadEmbeddedTextFile(Assembly.GetExecutingAssembly(), template); }
private static string DetermineTestPassOrFail(IReport report) { var hasPassed = true; foreach (var section in report.Sections().SelectMany(s => s.Sections())) { hasPassed = hasPassed && section.WasSuccessful; if (!hasPassed) { break; } } return hasPassed ? @"Passed" : @"Failed"; }
/// <summary> /// Creates the HTML that describes a report section. /// </summary> /// <param name="report">The report that contains the report section information.</param> /// <returns>A string containing the desired HTML.</returns> private static string CreateReportSectionHtml(IReport report) { var sortedSections = new List<Tuple<DateTimeOffset, string, TestSection>>(); foreach (var reportSection in report.Sections()) { foreach (var testSection in reportSection.Sections()) { sortedSections.Add(new Tuple<DateTimeOffset, string, TestSection>(testSection.StartTime, reportSection.Name, testSection)); } } sortedSections.Sort((first, second) => first.Item1.CompareTo(second.Item1)); var builder = new StringBuilder(); { int section = 0; foreach (var pair in sortedSections) { var sectionText = CreateTestSectionHtml(pair.Item2, pair.Item3, section % 2 == 0); builder.AppendLine(sectionText); section++; } } return builder.ToString(); }
/// <summary> /// Creates the XML that describes a report section. /// </summary> /// <param name="report">The report that contains the report section information.</param> /// <returns>A string containing the desired XML.</returns> private static string CreateReportSectionXml(IReport report) { var reportSectionTemplate = EmbeddedResourceExtracter.LoadEmbeddedTextFile( Assembly.GetExecutingAssembly(), @"Sherlock.Shared.Core.Reporting.Templates.ReportSectionTemplate.xml"); string reportSections = string.Empty; foreach (var reportSection in report.Sections()) { var testSections = CreateTestSectionXml(reportSection); var builder = new StringBuilder(reportSectionTemplate); { builder.Replace(@"${REPORT_SECTION_NAME}$", EscapeTextForUseInXml(reportSection.Name)); builder.Replace(@"${TEST_SECTIONS}$", testSections); } reportSections += builder.ToString(); } return reportSections; }