Beispiel #1
0
        public void CanSetValueBasedOnKey()
        {
            MockPropertyBag defaultPropertyBag = new MockPropertyBag();
            var             target             = new HierarchicalConfig(defaultPropertyBag, new MockConfigSettingSerializer());

            target.SetInPropertyBag("Key", 3, defaultPropertyBag);
        }
Beispiel #2
0
        public void SerializeErrorGivesClearErrroMessage()
        {
            MockPropertyBag defaultPropertyBag = new MockPropertyBag();
            var             target             = new HierarchicalConfig(defaultPropertyBag, new MockConfigSettingSerializer()
            {
                ThrowError = true
            });

            target.SetInPropertyBag("key", "MyValue", defaultPropertyBag);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public void GetValueWillUseHierarchy()
        {
            MockPropertyBag parent = BuildPropertyBagHierarcy();

            parent["value"] = "value";

            var target = new HierarchicalConfig(parent.Children.First());

            Assert.AreEqual("value", target.GetByKey <string>("value"));
        }
Beispiel #5
0
        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");
        }
Beispiel #6
0
        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"));
        }
Beispiel #7
0
        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);
        }