Example #1
0
		public void TestReport()
		{
			ReportSettings settings = new ReportSettings();
			settings.ReportDir = Path.GetTempPath();
			settings.ReportName = "Test";

			Stream expected = ResourceManager.GetResource("SharpCover.Resources.ExpectedCoverageFile.xml", typeof(CoverageTests).Assembly);
			Stream actual = ResourceManager.GetResource("SharpCover.Resources.ActualCoverageFile.xml", typeof(CoverageTests).Assembly);
			Stream fixedfile = Coverage.FixActualFile(actual);

			Coverage result = Coverage.LoadCoverage(expected, fixedfile);


			ReportGenerator generator = new ReportGenerator();
			Report report = generator.GenerateReport(result);
			
			DeleteFiles(settings);
			CheckFilesNotExist(settings);

			SetGradient();

			try
			{
				HtmlReport.Generate(settings, report);
				CheckFilesExist(settings);			
			}
			finally
			{
				DeleteFiles(settings);
				Gradient.GetInstance().Points.Clear();
			}
		}
        /// <summary>
        /// Executes this instance.
        /// </summary>
        /// <returns></returns>
		public decimal Execute()
		{
			try
			{
				CheckFileExists(settings.ActualFilename);
				CheckFileExists(settings.ExpectedFilename);
					
				Trace.WriteLineIf(Logger.OutputType.TraceInfo, String.Format("Generating Coverage Report for project {0} to \r\n{1}", 
                    settings.ReportName, settings.ReportFilename)); 
				
				var readactual = new FileStream(Settings.ActualFilename, FileMode.Open);
				Stream actual = Coverage.FixActualFile(readactual);
				var expected = new FileStream(settings.ExpectedFilename, FileMode.Open);
				
				Coverage coverage = Coverage.LoadCoverage(expected, actual);
	
				var generator = new ReportGenerator();
				Report report = generator.GenerateReport(coverage);
			
				History history = HistoryManager.LoadHistory(settings.HistoryFilename);
				HistoryManager.Update(history, report);
				HistoryManager.SaveHistory(history);
				report.History = history;
						
				HtmlReport.Generate(settings, report);

				Trace.WriteLineIf(Logger.OutputType.TraceInfo, "");
				Trace.WriteLineIf(Logger.OutputType.TraceInfo, String.Format("Overall coverage for project {1}: {0:P}", new object[] { report.CoveragePercentage, report.ReportName }));
				Trace.WriteLineIf(Logger.OutputType.TraceInfo, "");
			
				return report.CoveragePercentage;
			}
			catch(IOException ex)
			{
				Trace.WriteLine(ex.Message, "ERROR");
				return 0;
			}
		}
Example #3
0
		public void SetUp()
		{
			this.generator = new ReportGenerator();
		}