public void CanSetValueBasedOnKey() { MockPropertyBag defaultPropertyBag = new MockPropertyBag(); var target = new HierarchicalConfig(defaultPropertyBag, new MockConfigSettingSerializer()); target.SetInPropertyBag("Key", 3, defaultPropertyBag); }
public void SerializeErrorGivesClearErrroMessage() { MockPropertyBag defaultPropertyBag = new MockPropertyBag(); var target = new HierarchicalConfig(defaultPropertyBag, new MockConfigSettingSerializer() { ThrowError = true }); target.SetInPropertyBag("key", "MyValue", defaultPropertyBag); }
public void CanGetValueBasedOnKey() { MockPropertyBag defaultPropertyBag = new MockPropertyBag(); defaultPropertyBag["key"] = "3"; var target = new HierarchicalConfig(defaultPropertyBag, new MockConfigSettingSerializer()); int configValue = target.GetByKey <int>("key"); Assert.AreEqual(3, configValue); }
public void GetValueWillUseHierarchy() { MockPropertyBag parent = BuildPropertyBagHierarcy(); parent["value"] = "value"; var target = new HierarchicalConfig(parent.Children.First()); Assert.AreEqual("value", target.GetByKey <string>("value")); }
public void DeSerializeErrorGivesClearErrroMessage() { MockPropertyBag defaultPropertyBag = new MockPropertyBag(); defaultPropertyBag.values.Add("key", "abc"); var target = new HierarchicalConfig(defaultPropertyBag, new MockConfigSettingSerializer() { ThrowError = true }); target.GetByKey <DateTime>("key"); }
public void KeyExistsWillUseHierarchy() { MockPropertyBag parent = BuildPropertyBagHierarcy(); var target = new HierarchicalConfig(parent.Children.First()); Assert.IsFalse(target.ContainsKey("value")); parent["value"] = "value"; Assert.IsTrue(target.ContainsKey("value")); }
private MockPropertyBag BuildPropertyBagHierarcy() { MockPropertyBag parent = new MockPropertyBag(); MockPropertyBag child1 = new MockPropertyBag() { Parent = parent }; MockPropertyBag child2 = new MockPropertyBag() { Parent = parent }; parent.Children = new IPropertyBag[] { child1, child2 }; return(parent); }