public void AppSettingOverridesGlobalAndEnvSettingsTest() { var envScope = ConfigSettingScope.Create("DEV"); var appScope = ConfigSettingScope.Create("DEV", "APP1"); var all = new[] { new ConfigSetting("a", "1"), new ConfigSetting("b", "2"), new ConfigSetting("c", "3"), new ConfigSetting("a", "11") { Scope = envScope }, new ConfigSetting("a", "111") { Scope = appScope }, }; var effectiveGlobal = EffectiveSettingsEvaluator.GetEffectiveAsDict(all, ConfigSettingScope.Global); var effectiveForEnv = EffectiveSettingsEvaluator.GetEffectiveAsDict(all, envScope); var effectiveForApp = EffectiveSettingsEvaluator.GetEffectiveAsDict(all, appScope); Assert.AreEqual("1", effectiveGlobal["a"].Definition); Assert.AreEqual("11", effectiveForEnv["a"].Definition); Assert.AreEqual("111", effectiveForApp["a"].Definition); }
public void EnvironmentsDoNotInterferWithEachOtherTest() { var env1Scope = ConfigSettingScope.Create("DEV"); var env2Scope = ConfigSettingScope.Create("QA"); var all = new[] { new ConfigSetting("a", "1"), new ConfigSetting("b", "2"), new ConfigSetting("c", "3"), new ConfigSetting("a", "4") { Scope = env1Scope }, new ConfigSetting("a", "5") { Scope = env2Scope }, }; var effectiveForEnv1 = EffectiveSettingsEvaluator.GetEffectiveAsDict(all, env1Scope); var effectiveForEnv2 = EffectiveSettingsEvaluator.GetEffectiveAsDict(all, env2Scope); Assert.AreEqual("4", effectiveForEnv1["a"].Definition); Assert.AreEqual("5", effectiveForEnv2["a"].Definition); }
public void EnvBoundApplicableToBothEnvAndAppBoundTest() { var envBound = ConfigSettingScope.Create("DEV", null); var envAppBound = ConfigSettingScope.Create("DEV", "APP2"); Assert.IsTrue(envBound.IsApplicableTo(envAppBound)); Assert.IsFalse(envAppBound.IsApplicableTo(envBound)); }
public void AppBoundNotApplicableToEnvBoundAndTheOppositeTest() { var envBound = ConfigSettingScope.Create("DEV", null); var appBound = ConfigSettingScope.Create(null, "APP2"); Assert.IsFalse(envBound.IsApplicableTo(appBound)); Assert.IsFalse(appBound.IsApplicableTo(envBound)); }
public void GlobalIsApplicableToEverythingTest() { ConfigSettingScope global = ConfigSettingScope.Global; Assert.IsTrue(global.IsApplicableTo(ConfigSettingScope.Global)); Assert.IsTrue(global.IsApplicableTo(ConfigSettingScope.Create("DEV"))); Assert.IsTrue(global.IsApplicableTo(ConfigSettingScope.Create("DEV", "APP1"))); Assert.IsTrue(global.IsApplicableTo(ConfigSettingScope.Create("DEV", "APP1", "INST1"))); }
public IDictionary <string, string> GetAllInterpolated( string environment = null, string app = null, string appInstance = null) { var targetScope = ConfigSettingScope.Create(environment, app, appInstance); var ocs = new ObjectConfigStore(_config); var client = new ConfigClient(ocs, targetScope); return(client.GetAll()); }
public void DifferentAppScopesNotApplicableToEachOtherTest() { var app1Scope = ConfigSettingScope.Create("DEV", "APP1"); var app2Scope = ConfigSettingScope.Create("DEV", "APP2"); Assert.IsFalse(app1Scope.IsApplicableTo(app2Scope)); Assert.IsFalse(app2Scope.IsApplicableTo(app1Scope)); // the same with unspecified env app1Scope = ConfigSettingScope.Create(null, "APP1"); app2Scope = ConfigSettingScope.Create(null, "APP2"); Assert.IsFalse(app1Scope.IsApplicableTo(app2Scope)); Assert.IsFalse(app2Scope.IsApplicableTo(app1Scope)); }