Example #1
0
        public void Initialize_CanGetGetExeToolPathFromSetupConfigurationForBuildAgent()
        {
            // Arrange
            var logger = new TestLogger();

            var factory = CreateVisualStudioSetupConfigurationFactory("Microsoft.VisualStudio.TestTools.CodeCoverage.Msi");

            var reporter = new BinaryToXmlCoverageReportConverter(factory, logger, new AnalysisConfig());

            // Act
            var result = reporter.Initialize();

            // Assert
            result.Should().BeTrue();

            logger.AssertDebugLogged("Code coverage command line tool: x:\\foo\\Team Tools\\Dynamic Code Coverage Tools\\CodeCoverage.exe");
        }
Example #2
0
        public void Initialize_CanGetGetExeToolPathFromSetupConfiguration()
        {
            // Arrange
            var logger = new TestLogger();

            var factory = CreateVisualStudioSetupConfigurationFactory("Microsoft.VisualStudio.TestTools.CodeCoverage");

            var reporter = new CoverageReportConverter(factory);

            // Act
            var result = reporter.Initialize(logger);

            // Assert
            Assert.IsTrue(result);

            logger.AssertDebugLogged("Code coverage command line tool: x:\\foo\\Team Tools\\Dynamic Code Coverage Tools\\CodeCoverage.exe");
        }
Example #3
0
        public void Initialize_CanGetGetExeToolPathFromEnvironmentVariable_FileDoesntExist_ShouldFallback()
        {
            // Arrange
            var logger  = new TestLogger();
            var config  = new AnalysisConfig();
            var factory = CreateVisualStudioSetupConfigurationFactory("Microsoft.VisualStudio.TestTools.CodeCoverage");

            config.SetVsCoverageConverterToolPath(Path.GetTempPath());

            var reporter = new BinaryToXmlCoverageReportConverter(factory, logger, config);

            // Act
            var result = reporter.Initialize();

            // Assert
            result.Should().BeTrue();

            logger.Warnings.Contains("CodeCoverage.exe was not found in the standard locations. Please provide the full path of the tool using the VsTestToolsInstallerInstalledToolLocation variable.");
            logger.AssertDebugLogged("Code coverage command line tool: x:\\foo\\Team Tools\\Dynamic Code Coverage Tools\\CodeCoverage.exe");
        }
Example #4
0
        public void Initialize_CanGetGetExeToolPathFromEnvironmentVariable_FullPathToCodeCoverageToolGiven()
        {
            // Arrange
            var logger   = new TestLogger();
            var config   = new AnalysisConfig();
            var filePath = Path.Combine(Environment.CurrentDirectory, "CodeCoverage.exe");

            File.Create(filePath);
            config.SetVsCoverageConverterToolPath(filePath);

            var reporter = new BinaryToXmlCoverageReportConverter(logger, config);

            // Act
            var result = reporter.Initialize();

            // Assert
            result.Should().BeTrue();

            logger.AssertDebugLogged($@"CodeCoverage.exe found at {filePath}.");
        }
Example #5
0
        public void Initialize_CanGetGetExeToolPathFromEnvironmentVariable_NoExeInThePath_ShouldSeekForStandardInstall()
        {
            // Arrange
            var logger = new TestLogger();
            var config = new AnalysisConfig();

            var filePath = Path.Combine(Environment.CurrentDirectory, @"tools\net451\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe");

            Directory.CreateDirectory(Path.GetDirectoryName(filePath));
            File.Create(filePath);

            config.SetVsCoverageConverterToolPath(Environment.CurrentDirectory);

            var reporter = new BinaryToXmlCoverageReportConverter(logger, config);

            // Act
            var result = reporter.Initialize();

            // Assert
            result.Should().BeTrue();
            logger.AssertDebugLogged($@"CodeCoverage.exe found at {filePath}.");
        }