private void VerifyProjectBaseDir(string expectedValue, string teamBuildValue, string userValue, string[] projectPaths)
        {
            AnalysisConfig   config = new AnalysisConfig();
            PropertiesWriter writer = new PropertiesWriter(config);

            config.SonarOutputDir = TestSonarqubeOutputDir;

            config.SourcesDirectory = teamBuildValue;
            config.SetConfigValue(SonarProperties.ProjectBaseDir, userValue);

            using (new AssertIgnoreScope())
            {
                foreach (string projectPath in projectPaths)
                {
                    var projectInfo = new ProjectInfo {
                        FullPath = projectPath, ProjectLanguage = ProjectLanguages.CSharp
                    };
                    writer.WriteSettingsForProject(projectInfo, Enumerable.Empty <string>(), "", "");
                }

                var actual   = writer.Flush();
                var expected = "\r\nsonar.projectBaseDir=" + PropertiesWriter.Escape(expectedValue);

                Assert.IsTrue(actual.Contains(expected));
            }
        }
Esempio n. 2
0
        public void ConfigExt_GetAndSet()
        {
            // 0. Setup
            var config = new AnalysisConfig();

            string result;

            // 1. Get missing setting -> default returned
            result = config.GetConfigValue("missing", "123");
            Assert.AreEqual("123", result, "Unexpected config value returned");

            // 2. Set and get a new setting
            config.SetConfigValue("id1", "value1");
            Assert.AreEqual("value1", config.GetConfigValue("id1", "XXX"), "Unexpected config value returned");

            // 3. Update an existing setting
            config.SetConfigValue("id1", "value2");
            Assert.AreEqual("value2", config.GetConfigValue("id1", "XXX"), "Unexpected config value returned");
        }
        public void ConfigExt_GetAndSet()
        {
            // 0. Setup
            AnalysisConfig config = new AnalysisConfig();

            string result;

            // 1. Get missing setting -> default returned
            result = config.GetConfigValue("missing", "123");
            Assert.AreEqual("123", result, "Unexpected config value returned");

            // 2. Set and get a new setting
            config.SetConfigValue("id1", "value1");
            Assert.AreEqual("value1", config.GetConfigValue("id1", "XXX"), "Unexpected config value returned");

            // 3. Update an existing setting
            config.SetConfigValue("id1", "value2");
            Assert.AreEqual("value2", config.GetConfigValue("id1", "XXX"), "Unexpected config value returned");
        }
Esempio n. 4
0
        private void VerifyProjectBaseDir(string expectedValue, string teamBuildValue, string userValue, string[] projectPaths)
        {
            AnalysisConfig   config = new AnalysisConfig();
            PropertiesWriter writer = new PropertiesWriter(config);

            config.SonarOutputDir = TestSonarqubeOutputDir;

            config.SourcesDirectory = teamBuildValue;
            config.SetConfigValue(SonarProperties.ProjectBaseDir, userValue);

            TestLogger logger = new TestLogger();

            // Act
            string result = PropertiesFileGenerator.ComputeRootProjectBaseDir(config, projectPaths.Select(p => new ProjectInfo {
                FullPath = p, ProjectLanguage = ProjectLanguages.CSharp
            }));

            result.Should().Be(expectedValue);
        }
Esempio n. 5
0
 public static void SetBuildUri(this AnalysisConfig config, string uri)
 {
     config.SetConfigValue(BuildUriSettingId, uri);
 }
Esempio n. 6
0
 public static void SetVsCoverageConverterToolPath(this AnalysisConfig config, string path)
 {
     config.SetConfigValue(VsCoverageConverterToolPathId, path);
 }