예제 #1
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");
        }
        /// <summary>
        /// Appends the sonar.projectBaseDir value. This is calculated as follows:
        /// 1. the user supplied value, or if none
        /// 2. the sources directory if running from TFS Build or XAML Build, or
        /// 3. the common root path of projects, or if there isn't any
        /// 4. the .sonarqube/out directory
        /// </summary>
        public static string ComputeProjectBaseDir(AnalysisConfig config, IEnumerable <ProjectInfo> projects)
        {
            string projectBaseDir = config.GetConfigValue(SonarProperties.ProjectBaseDir, null);

            if (!string.IsNullOrWhiteSpace(projectBaseDir))
            {
                return(projectBaseDir);
            }

            projectBaseDir = config.SourcesDirectory;
            if (!string.IsNullOrWhiteSpace(projectBaseDir))
            {
                return(projectBaseDir);
            }

            projectBaseDir = GetCommonRootOfProjects(projects);
            if (!string.IsNullOrWhiteSpace(projectBaseDir))
            {
                return(projectBaseDir);
            }

            return(config.SonarOutputDir);
        }
예제 #4
0
 public static string GetBuildUri(this AnalysisConfig config)
 {
     return(config.GetConfigValue(BuildUriSettingId, null));
 }
예제 #5
0
 public static string GetVsCoverageConverterToolPath(this AnalysisConfig config)
 {
     return(config.GetConfigValue(VsCoverageConverterToolPathId, null));
 }