private static void WriteReport(Report report, string filename) { using (StreamWriter sw = new StreamWriter(filename, false, Encoding.UTF8)) { Serialization.ToXml(sw.BaseStream, report, false); } }
private void PopulateNamespaces(Report report, Coverage coverage) { foreach(CoveragePoint point in coverage.CoveragePoints) { if(!string.IsNullOrEmpty(point.Namespace) && !report.Namespaces.Contains(point.Namespace)) { report.Namespaces.Add(new Namespace() { Name = point.Namespace }); } } }
public void TestUpdate() { Assert.AreEqual(1, this.history.Events.Count); Assert.AreEqual(0.2M, this.history.GetLastEvent().CoveragePercentage); Report report = new Report(); HistoryManager.Update(this.history, report); Assert.AreEqual(2, this.history.Events.Count); Assert.AreEqual(0, this.history.GetLastEvent().CoveragePercentage); }
private static XPathDocument ConvertReportToXPathDocument(Report report) { MemoryStream ms = new MemoryStream(); SharpCover.Utilities.Serialization.ToXml(ms, report, false); ms.Seek(0,0); XPathDocument doc = new XPathDocument(ms); ms.Close(); return doc; }
/// <summary> /// Generates the report. /// </summary> /// <param name="coverage">The coverage.</param> /// <returns></returns> public Report GenerateReport(Coverage coverage) { Report report = new Report(); report.SharpCoverVersion = this.GetType().Assembly.GetName().Version.ToString(); report.ReportDate = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); report.ReportName = coverage.Settings.ReportName; report.SourceDir = coverage.Settings.BaseDir; PopulateNamespaces(report, coverage); foreach(Namespace ns in report.Namespaces) { PopulateNamespace(ns, coverage); } return report; }
/// <summary> /// Generates the specified settings. /// </summary> /// <param name="settings">The settings.</param> /// <param name="report">The report.</param> public static void Generate(ReportSettings settings, Report report) { // Load the transform XslCompiledTransform transform = LoadTransform("SharpCover.Report.xslt"); // Save the required stylesheet and images to the output folder WriteResource(settings.CssFilename, "SharpCover.SharpCover.css", ResourceType.Text); WriteResource(settings.GetFilename("SharpCover", ".gif"), "SharpCover.SharpCover.gif", ResourceType.Binary); // Write the xml report to disk WriteReport(report, settings.ReportXmlFilename); // Convert the report to a format we can transform XPathDocument doc = ConvertReportToXPathDocument(report); // Do the transform and write the results to disk WriteReport(transform, doc, settings.ReportFilename); }
public void SetUp() { this.report = new Report(); }
/// <summary> /// Updates historical coverage percentages, and returns the up to date history. /// </summary> public static void Update(History history, Report report) { Update(history, report.CoveragePercentage); }