Exemplo n.º 1
0
        public void ProcessCoverageReports_Standalone_WhenProcess_ReturnsTrue()
        {
            // Arrange
            var analysisConfig = new AnalysisConfig {
                LocalSettings = new AnalysisProperties()
            };
            var settings = new MockTeamBuildSettings {
                BuildEnvironment = BuildEnvironment.NotTeamBuild
            };
            var logger = new TestLogger();

            var testSubject = new CoverageReportProcessor(legacyFactoryMock.Object, converterMock.Object, logger);

            testSubject.Initialise(analysisConfig, settings);

            // Act
            var result = false;

            using (new AssertIgnoreScope())
            {
                result = testSubject.ProcessCoverageReports();
            }

            // Assert
            result.Should().BeTrue(); // false would cause the remaining processing to stop
            legacyFactoryMock.Verify(x => x.BuildTfsLegacyCoverageReportProcessor(), Times.Never);
        }
Exemplo n.º 2
0
        public void ProcessCoverageReports_LegacyTeamBuild_SkipCoverageIsFalse_WhenProcess_CallsLegacyFactoryThenCallsReturnedProcessor()
        {
            // Arrange
            var analysisConfig = new AnalysisConfig {
                LocalSettings = new AnalysisProperties()
            };
            var settingsMock = new MockTeamBuildSettings {
                BuildEnvironment = BuildEnvironment.LegacyTeamBuild
            };
            var logger = new TestLogger();

            // Set up the factory to return a processor that returns success
            var processorMock = new Mock <ICoverageReportProcessor>();

            processorMock.Setup(x => x.Initialise(It.IsAny <AnalysisConfig>(), It.IsAny <ITeamBuildSettings>())).Returns(true);
            processorMock.Setup(x => x.ProcessCoverageReports()).Returns(true);
            legacyFactoryMock.Setup(x => x.BuildTfsLegacyCoverageReportProcessor()).Returns(processorMock.Object);

            using (var scope = new EnvironmentVariableScope())
            {
                scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SkipLegacyCodeCoverage, "false");

                var testSubject = new CoverageReportProcessor(legacyFactoryMock.Object, converterMock.Object, logger);
                testSubject.Initialise(analysisConfig, settingsMock);

                // Act
                var result = testSubject.ProcessCoverageReports();

                // Assert
                result.Should().BeTrue();
                legacyFactoryMock.Verify(x => x.BuildTfsLegacyCoverageReportProcessor(), Times.Once);
                processorMock.Verify(x => x.Initialise(It.IsAny <AnalysisConfig>(), It.IsAny <ITeamBuildSettings>()), Times.Once);
                processorMock.Verify(x => x.ProcessCoverageReports(), Times.Once);
            }
        }
Exemplo n.º 3
0
        public void ProcessCoverageReports_LegacyTeamBuild_SkipCoverageIsTrue_WhenProcess_CallsLegacyFactoryThenCallsReturnedProcessor()
        {
            // Arrange
            var analysisConfig = new AnalysisConfig {
                LocalSettings = new AnalysisProperties()
            };
            var settingsMock = new MockTeamBuildSettings {
                BuildEnvironment = BuildEnvironment.LegacyTeamBuild
            };
            var logger = new TestLogger();

            using (var scope = new EnvironmentVariableScope())
            {
                scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SkipLegacyCodeCoverage, "true");

                var testSubject = new CoverageReportProcessor(legacyFactoryMock.Object, converterMock.Object, logger);
                testSubject.Initialise(analysisConfig, settingsMock);

                // Act
                var result = false;
                using (new AssertIgnoreScope())
                {
                    result = testSubject.ProcessCoverageReports();
                }

                // Assert
                result.Should().BeTrue();
                legacyFactoryMock.Verify(x => x.BuildTfsLegacyCoverageReportProcessor(), Times.Never);
            }
        }