public void CascadeSettingsContainer_GetEffectiveValue_EvaluatesSettingScope() { CascadeSettingsContainer container = new CascadeSettingsContainer(); var sourceA = container.AddSource(new CustomDataSource()); var sourceB = container.AddSource(new CustomDataSource()); sourceA.Data["key1"] = "value1A"; sourceB.Data["key1"] = "value2A"; sourceA.Scope = SettingScopeEnum.Application; sourceB.Scope = SettingScopeEnum.User; Assert.Equal("value2A", container.GetEffectiveValue("key1")); Assert.Equal("value2A", container.GetEffectiveValue("key1", SettingScopeEnum.User)); Assert.Equal("value1A", container.GetEffectiveValue("key1", SettingScopeEnum.Application)); }
public void CascadeSettingsContainer_GetEffectiveValue_ReturnsLastValueInSourcesOrder() { CascadeSettingsContainer container = new CascadeSettingsContainer(); var sourceA = container.AddSource(new CustomDataSource()); var sourceB = container.AddSource(new CustomDataSource()); sourceA.Data["key1"] = "value1A"; sourceB.Data["key1"] = "value1B"; sourceA.Data["key2"] = "value2A"; sourceB.Data["key3"] = "value3B"; Assert.Equal("value1B", container.GetEffectiveValue("key1")); Assert.Equal("value2A", container.GetEffectiveValue("key2")); Assert.Equal("value3B", container.GetEffectiveValue("key3")); Assert.Null(container.GetEffectiveValue("key4")); // unknown key }
public void CascadeSettingsContainer_GetEffectiveValue_ReturnsNullIfNoSources() { CascadeSettingsContainer container = new CascadeSettingsContainer(); Assert.Null(container.GetEffectiveValue("somekey")); }