Exemplo n.º 1
0
        public void TestInheritedFlagIsSetCorrectly()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("inheritanceSectionLocal").GetSection("clienta");
            Assert.IsNotNull(configSection);

            string globalKey1 = "mykey1";
            string globalKey2 = "globalkey";

            Assert.IsTrue(configSection.ValuesAsDictionary.ContainsKey(globalKey1));
            string globalValue = configSection.ValuesAsDictionary[globalKey1];

            Assert.IsFalse(string.IsNullOrEmpty(globalValue));

            CustomConfigurations.ConfigSection childSection = configSection.Collections.GetCollection("child");
            Assert.IsNotNull(childSection);
            Assert.IsTrue(childSection.ValuesAsDictionary.ContainsKey(globalKey1));
            Assert.AreNotEqual(globalValue, childSection.ValuesAsDictionary[globalKey1]);
            Assert.AreEqual("123", childSection.ValuesAsDictionary[globalKey1]);

            ConfigValueDictionary values = childSection.ValuesAsDictionary;

            Assert.AreEqual(3, values.Count);

            string childKey = "mykey2";

            Assert.IsTrue(childSection.ValuesAsDictionary.ContainsKey(childKey));
            Assert.IsFalse(values.IsInherited(globalKey1));
            Assert.IsFalse(values.IsInherited(childKey));
            Assert.IsTrue(values.IsInherited(globalKey2));
        }