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); } }
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); }
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); } }
public void Initialize_Checks_Arguments_For_Null() { // Arrange var analysisConfig = new AnalysisConfig(); Action act = () => processor.Initialise(analysisConfig, null); // Act & Assert act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("settings"); }
private static void ExecuteCoverageConverter(ILogger logger, AnalysisConfig config, ILegacyTeamBuildFactory teamBuildFactory, ITeamBuildSettings teamBuildSettings, string fullPropertiesFilePath) { var binaryConverter = new BinaryToXmlCoverageReportConverter(logger, config); var coverageReportProcessor = new CoverageReportProcessor(teamBuildFactory, binaryConverter, logger); if (coverageReportProcessor.Initialise(config, teamBuildSettings, fullPropertiesFilePath)) { bool success = coverageReportProcessor.ProcessCoverageReports(); if (success) { logger.LogInfo("Coverage report conversion completed successfully."); } else { logger.LogWarning("Coverage report conversion has failed. Skipping..."); } } }