public void ReportProcessor_CannotConvertFiles() { // Arrange MockReportUrlProvider urlProvider = new MockReportUrlProvider() { UrlsToReturn = new string[] { ValidUrl1 } }; MockReportDownloader downloader = new MockReportDownloader(); MockReportConverter converter = new MockReportConverter() { CanConvert = false }; AnalysisConfig context = this.CreateValidContext(); TeamBuildSettings settings = this.CreateValidSettings(); TestLogger logger = new TestLogger(); TfsLegacyCoverageReportProcessor processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter); // Act bool initResult = processor.Initialise(context, settings, logger); // Assert Assert.IsFalse(initResult, "Expecting false: processor should not have been initialised successfully"); urlProvider.AssertGetUrlsNotCalled(); downloader.AssertDownloadNotCalled(); converter.AssertConvertNotCalled(); logger.AssertWarningsLogged(0); logger.AssertErrorsLogged(0); }
public void ReportProcessor_MultipleUrlsFound() { // Arrange MockReportUrlProvider urlProvider = new MockReportUrlProvider() { UrlsToReturn = new string[] { ValidUrl1, ValidUrl2 } }; MockReportDownloader downloader = new MockReportDownloader(); MockReportConverter converter = new MockReportConverter() { CanConvert = true }; AnalysisConfig context = this.CreateValidContext(); TeamBuildSettings settings = this.CreateValidSettings(); TestLogger logger = new TestLogger(); TfsLegacyCoverageReportProcessor processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter); // Act bool initResult = processor.Initialise(context, settings, logger); Assert.IsTrue(initResult, "Expecting true: processor should have been initialised successfully"); bool result = processor.ProcessCoverageReports(); // Assert urlProvider.AssertGetUrlsCalled(); downloader.AssertDownloadNotCalled(); // Multiple urls so should early out converter.AssertConvertNotCalled(); Assert.IsFalse(result, "Expecting false: can't process multiple coverage reports"); logger.AssertErrorsLogged(1); logger.AssertWarningsLogged(0); }
public void ReportProcessor_NoUrlsFound() { // Arrange MockReportUrlProvider urlProvider = new MockReportUrlProvider() { UrlsToReturn = new string[] { } }; MockReportDownloader downloader = new MockReportDownloader(); MockReportConverter converter = new MockReportConverter() { CanConvert = true }; AnalysisConfig context = this.CreateValidContext(); TeamBuildSettings settings = this.CreateValidSettings(); TestLogger logger = new TestLogger(); TfsLegacyCoverageReportProcessor processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter); // Act bool initResult = processor.Initialise(context, settings, logger); Assert.IsTrue(initResult, "Expecting true: processor should have been initialised successfully"); bool result = processor.ProcessCoverageReports(); // Assert urlProvider.AssertGetUrlsCalled(); downloader.AssertDownloadNotCalled(); // no urls returned, so should go any further converter.AssertConvertNotCalled(); Assert.IsTrue(result, "Expecting true: no coverage reports is a valid scenario"); logger.AssertWarningsLogged(0); logger.AssertErrorsLogged(0); }