Ejemplo n.º 1
0
        private static void WriteReport(Report report, string filename)
		{
            using (StreamWriter sw = new StreamWriter(filename, false, Encoding.UTF8))
            {
                Serialization.ToXml(sw.BaseStream, report, false);
            }
		}
Ejemplo n.º 2
0
		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 });
				}
			}
		}
Ejemplo n.º 3
0
		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);
		}
Ejemplo n.º 4
0
		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;
		}
Ejemplo n.º 5
0
        /// <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;
		}
Ejemplo n.º 6
0
        /// <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);
		}
Ejemplo n.º 7
0
		public void SetUp()
		{
			this.report = new Report();
		}
Ejemplo n.º 8
0
		/// <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);
		}