public void ReportProcessor_CannotConvertFiles()
        {
            // Arrange
            var urlProvider = new MockReportUrlProvider()
            {
                UrlsToReturn = new string[] { ValidUrl1 }
            };
            var downloader = new MockReportDownloader();
            var converter  = new MockReportConverter()
            {
                CanConvert = false
            };
            var context  = CreateValidContext();
            var settings = CreateValidSettings();
            var logger   = new TestLogger();

            var processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter);

            // Act
            var 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_NoUrlsFound()
        {
            // Arrange
            var urlProvider = new MockReportUrlProvider()
            {
                UrlsToReturn = new string[] { }
            };
            var downloader = new MockReportDownloader();
            var converter  = new MockReportConverter()
            {
                CanConvert = true
            };
            var context  = CreateValidContext();
            var settings = CreateValidSettings();
            var logger   = new TestLogger();

            var processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter);

            // Act
            var initResult = processor.Initialise(context, settings, logger);

            Assert.IsTrue(initResult, "Expecting true: processor should have been initialised successfully");
            var 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);
        }
        public void ReportProcessor_MultipleUrlsFound()
        {
            // Arrange
            var urlProvider = new MockReportUrlProvider()
            {
                UrlsToReturn = new string[] { ValidUrl1, ValidUrl2 }
            };
            var downloader = new MockReportDownloader();
            var converter  = new MockReportConverter()
            {
                CanConvert = true
            };
            var context  = CreateValidContext();
            var settings = CreateValidSettings();
            var logger   = new TestLogger();

            var processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter);

            // Act
            var initResult = processor.Initialise(context, settings, logger);

            Assert.IsTrue(initResult, "Expecting true: processor should have been initialised successfully");
            var 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);
        }
Esempio n. 4
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 result = processor.ProcessCoverageReports(context, settings, logger);

            // 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);
        }
Esempio n. 5
0
        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 result = processor.ProcessCoverageReports(context, settings, logger);

            // Assert
            urlProvider.AssertGetUrlsNotCalled();
            downloader.AssertDownloadNotCalled();
            converter.AssertConvertNotCalled();
            Assert.IsFalse(result, "Expecting result to be false as files could not be converted");

            logger.AssertWarningsLogged(0);
            logger.AssertErrorsLogged(0);
        }
Esempio n. 6
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 result = processor.ProcessCoverageReports(context, settings, logger);

            // 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
            var urlProvider = new MockReportUrlProvider()
            {
                UrlsToReturn = new string[] { }
            };
            var downloader = new MockReportDownloader();
            var converter  = new MockReportConverter()
            {
                CanConvert = true
            };
            var context  = CreateValidContext();
            var settings = CreateValidSettings();
            var logger   = new TestLogger();
            var testDir  = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            var processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter, logger);

            // Act
            var initResult = processor.Initialise(context, settings, testDir + "\\sonar-project.properties");

            initResult.Should().BeTrue("Expecting true: processor should have been initialized successfully");
            var result = processor.ProcessCoverageReports();

            // Assert
            urlProvider.AssertGetUrlsCalled();
            downloader.AssertDownloadNotCalled(); // no urls returned, so should go any further
            converter.AssertConvertNotCalled();
            result.Should().BeTrue("Expecting true: no coverage reports is a valid scenario");

            logger.AssertWarningsLogged(0);
            logger.AssertErrorsLogged(0);
        }