public void ProjectInfo_ExtensionMethods_GetAndSet()
        {
            // 0. Setup
            AnalysisConfig config = new AnalysisConfig();

            AnalysisSetting setting;
            string          result;

            // 1. Get/TryGet missing setting
            result = config.GetSetting("missing", "123");

            Assert.IsFalse(config.TryGetSetting("missing", out setting), "Setting should not have been found");
            Assert.AreEqual("123", config.GetSetting("missing", "123"), "Expecting the default setting to be returned");

            // 2. Set and get a previously new setting
            config.SetValue("id1", "value1");
            Assert.IsTrue(config.TryGetSetting("id1", out setting), "Setting should have been found");
            Assert.AreEqual("value1", setting.Value, "Unexpected value returned for setting");
            Assert.AreEqual("value1", config.GetSetting("id1", "123"), "Unexpected value returned for setting");

            // 3. Update and refetch the setting
            config.SetValue("id1", "updated value");
            Assert.IsTrue(config.TryGetSetting("id1", out setting), "Setting should have been found");
            Assert.AreEqual("updated value", setting.Value, "Unexpected value returned for setting");
            Assert.AreEqual("updated value", config.GetSetting("id1", "123"), "Unexpected value returned for setting");
        }
        private void FetchSonarQubeProperties(AnalysisConfig config, SonarWebService ws)
        {
            var properties = this.propertiesFetcher.FetchProperties(ws, config.SonarProjectKey);

            foreach (var property in properties)
            {
                config.SetValue(property.Key, property.Value);
            }
        }
        /// <summary>
        /// Ensures an analysis config file exists in the specified directory,
        /// replacing one if it already exists.
        /// If the supplied "regExExpression" is not null then the appropriate setting
        /// entry will be created in the file
        /// </summary>
        private static void EnsureAnalysisConfig(string parentDir, string regExExpression)
        {
            AnalysisConfig config = new AnalysisConfig();

            if (regExExpression != null)
            {
                config.SetValue(IsTestFileByName.TestRegExSettingId, regExExpression);
            }

            string fullPath = Path.Combine(parentDir, FileConstants.ConfigFileName);

            if (File.Exists(fullPath))
            {
                File.Delete(fullPath);
            }
            config.Save(fullPath);
        }
Example #4
0
 public static void SetBuildUri(this AnalysisConfig config, string uri)
 {
     config.SetValue(BuildUriSettingId, uri);
 }