public void WillReturnEmptyCoverageForNoInputFiles()
        {
            var parser       = new ReportGeneratorTool(new PublisherConfiguration());
            var fileCoverage = parser.GetFileCoverageInfos();
            var summary      = parser.GetCoverageSummary();

            Assert.AreEqual(fileCoverage.Count, 0);
            Assert.AreEqual(summary.CodeCoverageData.CoverageStats.Count, 0);

            Assert.AreEqual(_logger.Log.Trim(), @"
debug: ReportGeneratorTool: No input coverage files to parse.
debug: ReportGeneratorTool.GetFileCoverageInfos: Generating file coverage info from coverage files.
debug: ReportGeneratorTool.GetCoverageSummary: Generating coverage summary for the coverage files.
".Trim());
        }
        public void WillGenerateCorrectFileCoverage(string[] coverageFiles, string result)
        {
            var parser = new ReportGeneratorTool(new PublisherConfiguration()
            {
                CoverageFiles = coverageFiles
            });
            var fileCoverages = parser.GetFileCoverageInfos();
            var json          = JsonConvert.SerializeObject(fileCoverages);

            Assert.AreEqual(json, result);

            Assert.AreEqual(_logger.Log.Trim(), @"
debug: ReportGeneratorTool.ParseCoverageFiles: Parsing coverage files.
debug: ReportGeneratorTool.GetFileCoverageInfos: Generating file coverage info from coverage files.
".Trim());
        }
        public void WillGenerateCorrectCoverageSummary(string[] coverageFiles, string result)
        {
            var parser = new ReportGeneratorTool(new PublisherConfiguration()
            {
                CoverageFiles = coverageFiles
            });
            var summary = parser.GetCoverageSummary();
            var json    = JsonConvert.SerializeObject(summary.CodeCoverageData);

            Assert.AreEqual(json, result);

            Assert.AreEqual(_logger.Log.Trim(), @"
debug: ReportGeneratorTool.ParseCoverageFiles: Parsing coverage files.
debug: ReportGeneratorTool.GetCoverageSummary: Generating coverage summary for the coverage files.
".Trim());
        }
        public void WillReturnEmptyCoverageForNonExistingFile()
        {
            var parser = new ReportGeneratorTool(new PublisherConfiguration()
            {
                CoverageFiles = new string[] { "SampleCoverage/blabla.xml" }
            });
            var fileCoverage = parser.GetFileCoverageInfos();
            var summary      = parser.GetCoverageSummary();

            Assert.AreEqual(fileCoverage.Count, 0);
            Assert.AreEqual(summary.CodeCoverageData.CoverageStats[0].Total, 0);

            Assert.AreEqual(_logger.Log.Trim(), @"
debug: ReportGeneratorTool.ParseCoverageFiles: Parsing coverage files.
debug: ReportGeneratorTool.GetFileCoverageInfos: Generating file coverage info from coverage files.
debug: ReportGeneratorTool.GetCoverageSummary: Generating coverage summary for the coverage files.
".Trim());
        }
        public void WillGenerateHTMLReport(string[] xmlFiles)
        {
            var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            var parser = new ReportGeneratorTool(new PublisherConfiguration()
            {
                CoverageFiles   = xmlFiles,
                ReportDirectory = tempDir
            });

            parser.GenerateHTMLReport();

            Assert.IsTrue(Directory.EnumerateFiles(tempDir).Count() > 0);

            //cleanup
            Directory.Delete(tempDir, true);

            Assert.IsTrue(_logger.Log.Contains(@"
debug: ReportGeneratorTool.ParseCoverageFiles: Parsing coverage files.
debug: ReportGeneratorTool.CreateHTMLReportFromParserResult: Creating HTML report.
".Trim()));
        }