示例#1
0
        public void OverLayConfigConfigOneSectionWithinOneSectionWithinOneSection()
        {
            var stfConfiguration = new StfConfiguration();
            var conf1            = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\ConfigOneSectionWithinOneSectionWithinOneSection.xml");
            var conf2            = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\ConfigOneSectionWithinOneSectionWithinOneSection.xml");
            var overLay          = stfConfiguration.OverLay(conf1, conf2);

            DumpTree(overLay, @"overLay.xml");
            DumpTree(conf2, @"expected.xml");

            Assert.IsTrue(conf2.Identical(conf2, overLay));
        }
示例#2
0
        public void OverLay23()
        {
            var stfConfiguration = new StfConfiguration();
            var conf2            = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\Config2.xml");
            var conf3            = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\Config3.xml");
            var conf23           = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\Config23.xml");
            var overLay          = stfConfiguration.OverLay(conf2, conf3);

            DumpTree(overLay, @"overLay.xml");
            DumpTree(conf23, @"expected.xml");

            Assert.IsTrue(conf2.Identical(conf23, overLay));
        }
示例#3
0
        public void OverLayConfigWithDuplicatedSection()
        {
            var stfConfiguration = new StfConfiguration();
            var conf1            = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\ConfigWithDuplicatedSection.xml");
            var conf2            = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\ConfigWithDuplicatedSectionOverlay.xml");
            var overLay          = stfConfiguration.OverLay(conf1, conf2);
            var confExpected     = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\ConfigWithDuplicatedSectionExpected.xml");

            DumpTree(overLay, @"overLay.xml");
            DumpTree(confExpected, @"confExpected.xml");

            StfAssert.IsTrue("Comparing", confExpected.Identical(confExpected, overLay));
        }
示例#4
0
        public void LoadConfig2SubSections()
        {
            var stfConfiguration = new StfConfiguration();
            var conf             = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\Config1.xml");

            Assert.AreEqual(1, conf.Sections.Count, 1);
            var sectionTotest = conf.Sections["SectionName"];

            Assert.AreEqual("SectionName", sectionTotest.SectionName);
            Assert.AreEqual("SubSectionName1", sectionTotest.DefaultSection);
            Assert.AreEqual(2, sectionTotest.Sections.Count);
            Assert.AreEqual(1, sectionTotest.Keys.Count);
            Assert.AreEqual("config1_key1value", sectionTotest.Keys["k1"].KeyValue);

            // first subkey
            sectionTotest = conf.Sections["SectionName"].Sections["SubSectionName1"];
            Assert.AreEqual(1, sectionTotest.Keys.Count);
            Assert.AreEqual("SubSectionName1", sectionTotest.SectionName);
            Assert.IsTrue(string.IsNullOrEmpty(sectionTotest.DefaultSection));
            Assert.AreEqual("config1_subkey1value", sectionTotest.Keys["sk1"].KeyValue);
            Assert.AreEqual(0, sectionTotest.Sections.Count);

            // second subkey
            sectionTotest = conf.Sections["SectionName"].Sections["SubSectionName2"];
            Assert.AreEqual(1, sectionTotest.Keys.Count);
            Assert.AreEqual("SubSectionName2", sectionTotest.SectionName);
            Assert.IsTrue(string.IsNullOrEmpty(sectionTotest.DefaultSection));
            Assert.AreEqual("config1_subkey2value", sectionTotest.Keys["sk2"].KeyValue);
            Assert.AreEqual(0, sectionTotest.Sections.Count);
        }
示例#5
0
        public void ParserSimpleVariable2()
        {
            var stfConfiguration = new StfConfiguration();
            var conf             = stfConfiguration.LoadConfig(@"TestData\Parser\parser1.xml");

            var key2Value = stfConfiguration.GetKeyValue(conf, "SectionName.SubSectionName.k2");

            Assert.AreEqual("config_key2value", key2Value);
        }
示例#6
0
        public void OverLayNullWithSimple()
        {
            var stfConfiguration = new StfConfiguration();
            var conf2            = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\Config2.xml");
            var overLay          = stfConfiguration.OverLay(null, conf2);

            DumpTree(overLay, @"overLay.xml");
            DumpTree(conf2, @"expected.xml");

            Assert.IsTrue(conf2.Identical(conf2, overLay));
        }
示例#7
0
        public void LoadConfigTwoSectionsSideBySide()
        {
            var stfConfiguration = new StfConfiguration();
            var conf             = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\ConfigTwoSectionsSideBySide.xml");

            var sectionTotest = conf.Sections["SectionNameFirst"];

            Assert.AreEqual("SectionNameFirst", sectionTotest.SectionName);

            sectionTotest = conf.Sections["SectionNameSecond"];
            Assert.AreEqual("SectionNameSecond", sectionTotest.SectionName);
        }
示例#8
0
        public void LoadConfigOneSectionWithinOneSection()
        {
            var stfConfiguration = new StfConfiguration();
            var conf             = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\ConfigOneSectionWithinOneSection.xml");

            var sectionTotest = conf.Sections["SectionNameOuter"];

            Assert.AreEqual("SectionNameOuter", sectionTotest.SectionName);

            sectionTotest = sectionTotest.Sections["SectionNameInner"];
            Assert.AreEqual("SectionNameInner", sectionTotest.SectionName);
        }
示例#9
0
        public void LoadConfig1Section1Key()
        {
            var stfConfiguration = new StfConfiguration();
            var conf             = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\Config2.xml");

            Assert.AreEqual(1, conf.Sections.Count);
            var sectionTotest = conf.Sections["SectionName"];

            Assert.AreEqual("SectionName", sectionTotest.SectionName);
            Assert.AreEqual(0, sectionTotest.Sections.Count);
            Assert.AreEqual(1, sectionTotest.Keys.Count);
            Assert.AreEqual("config2_key1value", sectionTotest.Keys["k1"].KeyValue);
        }
示例#10
0
        public void LoadConfig1Section2Keys()
        {
            var stfConfiguration = new StfConfiguration();
            var conf             = stfConfiguration.LoadConfig(@"TestData\ConfigOverlay\Config3.xml");

            var sectionTotest = conf.Sections["SectionName"];

            Assert.AreEqual("SectionName", sectionTotest.SectionName);
            Assert.AreEqual(0, sectionTotest.Sections.Count);
            Assert.AreEqual(2, sectionTotest.Keys.Count);
            Assert.AreEqual("config3_key2value", sectionTotest.Keys["k2"].KeyValue);
            Assert.AreEqual("config3_key3value", sectionTotest.Keys["k3"].KeyValue);
        }
示例#11
0
        public void MakeCopyTests()
        {
            var stfConfiguration = new StfConfiguration();

            var configFiles = Directory.EnumerateFiles(".", "config*.xml");

            foreach (var configFile in configFiles)
            {
                var conf     = stfConfiguration.LoadConfig(configFile);
                var confCopy = conf.MakeCopy();

                DumpTree(conf, "Original" + configFile.Replace(@".\", string.Empty));
                DumpTree(confCopy, "Copy" + configFile.Replace(@".\", string.Empty));

                Assert.IsTrue(conf.Identical(conf, confCopy));
            }
        }