public void MachineSettings_NoConfig_NoError()
        {
            // Arrange - dir with no config settings
            string rootDir = TestUtils.CreateTestDirectory(TestContext);

            // Act
            IMachineWideSettings testSubject = new NuGetMachineWideSettings(rootDir);

            testSubject.Settings.Count().Should().Be(0, "Unexpected number of settings files");
        }
        public void MachineSettings_NoConfig_NoError()
        {
            // Arrange - dir with no config settings
            string rootDir = TestUtils.CreateTestDirectory(this.TestContext);

            // Act
            IMachineWideSettings testSubject = new NuGetMachineWideSettings(rootDir);

            Assert.AreEqual(0, testSubject.Settings.Count(), "Unexpected number of settings files");
        }
예제 #3
0
        public async Task TestNuGetMachineWideSettings()
        {
            await WriteNugetConfigToWorkingDirectoryAsync();

            var packageSources = new NuGetMachineWideSettings(_snapFilesystem, _baseFixture.WorkingDirectory);

            var configRoots     = packageSources.Settings.GetConfigRoots();
            var configFilePaths = packageSources.Settings.GetConfigFilePaths();

            Assert.NotEmpty(configRoots);
            Assert.NotEmpty(configFilePaths);
        }
        public void MachineSettings_MultipleFiles_MultipleLoaded()
        {
            // Arrange
            string baseDir = TestUtils.CreateTestDirectory(TestContext);

            CreateValidConfigFile(baseDir, "NuGet\\Config\\NuGet.config");         // valid file in root dir - should be loaded
            CreateValidConfigFile(baseDir, "NuGet\\Config\\SonarQube\\sq.config"); // valid file in SQ subdir - should be loaded

            CreateValidConfigFile(baseDir, "NuGet\\Config\\SonarQube\\sq.wrongExtension");
            CreateValidConfigFile(baseDir, "NuGet\\WrongFolder\\should.not.be.loaded.config");
            CreateValidConfigFile(baseDir, "WrongFolder\\should.not.be.loaded.config");

            // Act
            IMachineWideSettings testSubject = new NuGetMachineWideSettings(baseDir);

            // Assert
            AssertExpectedConfigFilesLoaded(testSubject, baseDir,
                                            "NuGet\\Config\\NuGet.config",
                                            "NuGet\\Config\\SonarQube\\sq.config");
        }
        public void MachineSettings_MultipleFiles_MultipleLoaded()
        {
            // Arrange
            string baseDir = TestUtils.CreateTestDirectory(this.TestContext);

            CreateValidConfigFile(baseDir, "NuGet\\Config\\NuGet.config"); // valid file in root dir - should be loaded
            CreateValidConfigFile(baseDir, "NuGet\\Config\\SonarQube\\sq.config"); // valid file in SQ subdir - should be loaded

            CreateValidConfigFile(baseDir, "NuGet\\Config\\SonarQube\\sq.wrongExtension");
            CreateValidConfigFile(baseDir, "NuGet\\WrongFolder\\should.not.be.loaded.config");
            CreateValidConfigFile(baseDir, "WrongFolder\\should.not.be.loaded.config");
            
            // Act
            IMachineWideSettings testSubject = new NuGetMachineWideSettings(baseDir);

            // Assert
            AssertExpectedConfigFilesLoaded(testSubject, baseDir,
                "NuGet\\Config\\NuGet.config",
                "NuGet\\Config\\SonarQube\\sq.config");
        }