public void TestConfNodeEditor_AddNode_ToTagParent()
        {
            ConfTree conf = Builder.Xml.Generate($@"{GlobalVar.SamplePath}/DefaultSpec.xml");

            conf.Save($@"{GlobalVar.ResultPath}\root.xml");
            conf = Builder.Xml.Generate($@"{GlobalVar.ResultPath}\root.xml");

            var node = conf.Find(@"Specs/BR", new List <string>()
            {
                "HighTemp"
            });

            Assert.IsTrue(node == null);

            ConfTree newnode = new ConfTree("BR");

            newnode.Add(new ConfItem("Max", "10"));
            newnode.Add(new ConfItem("Min", "0"));
            var tree = conf.GetItem(@"HighTemp:Specs") as ConfTree;

            tree.AddNode(newnode);
            conf.Save();

            conf = Builder.Xml.Generate($@"{GlobalVar.ResultPath}\root.xml");
            node = conf.Find(@"Specs/BR", new List <string>()
            {
                "HighTemp"
            });
            Assert.IsTrue(node != null);
        }
示例#2
0
        public void TestBuild_Dictionary_Save()
        {
            ConfTree conf = Builder.Generate(new Dictionary <string, string> {
                { "Item1", "Value1" },
                { "Item2", "Value2" },
            }, "DictConf1");

            Assert.IsTrue(conf["Item1"] == "Value1");
            Assert.IsTrue(conf["Item2"] == "Value2");

            JbAssert.Equal(conf.Find("Item1").Path, "/DictConf1(Default)");
            JbAssert.Equal(conf.Find("Item2").Path, "/DictConf1(Default)");

            Builder.Xml.Save(conf, $@"{GlobalVar.ResultPath}/DictConf1.xml");
        }
示例#3
0
        public void TestConfTree_AddItemToTree()
        {
            ConfTree conf = new ConfTree("TestBuildTree");

            Assert.IsTrue(conf.Name == "TestBuildTree");

            conf.Add(new ConfItem("Item1", "Value1"));
            Assert.IsTrue(conf["Item1"] == "Value1");
            Assert.IsTrue(conf.Find("Item1").Path == "/TestBuildTree");

            GlobalVar.Log.Debug(conf.ShowAll());
        }
示例#4
0
        public void TestConfTree_AddMixToTree2()
        {
            ConfTree tree1 = new ConfTree("Tree1");

            tree1.Add(new ConfItem("Item1-1", "Value1-1"));

            ConfTree tree2 = new ConfTree("Tree2");

            tree2.Add(new ConfItem("Item2-1", "Value2-1"));
            tree2.Add(new ConfItem("Item2-2", "Value2-2"));

            ConfTree tree3 = new ConfTree("Tree3");

            tree3.Add(new ConfItem("Item3-1", "Value3-1"));
            tree3.Add(new ConfItem("Item3-2", "Value3-2"));

            tree1.Add(tree2);
            tree2.Add(tree3);

            Assert.IsTrue(tree1.Find("Item1-1").Path == "/Tree1");
            Assert.IsTrue(tree1.Find("Tree2").Path == "/Tree1");
            Assert.IsTrue(tree1.Find("Item2-1").Path == "/Tree1/Tree2");
            Assert.IsTrue(tree1.Find("Tree3").Path == "/Tree1/Tree2");
            Assert.IsTrue(tree1.Find("Item3-1").Path == "/Tree1/Tree2/Tree3");
            Assert.IsTrue(tree1.Find("Item3-2").Path == "/Tree1/Tree2/Tree3");

            GlobalVar.Log.Debug(tree1.ShowAll());
        }
        public void TestConfNodeEditor_RemoveNode()
        {
            ConfTree conf = Builder.Xml.Generate($@"{GlobalVar.SamplePath}/DefaultSpec.xml");

            conf.Save($@"{GlobalVar.ResultPath}\root.xml");
            conf = Builder.Xml.Generate($@"{GlobalVar.ResultPath}\root.xml");

            var node = conf.Find(@"Specs/Ith", new List <string>()
            {
                "HighTemp"
            });

            Assert.IsTrue(node != null);

            conf.RemoveNode(node);

            conf = Builder.Xml.Generate($@"{GlobalVar.ResultPath}\root.xml");
            node = conf.Find(@"Specs/Ith", new List <string>()
            {
                "HighTemp"
            });
            Assert.IsTrue(node == null);
        }
示例#6
0
        public void TestBuild_Xml_CheckPath()
        {
            ConfTree conf = Builder.Xml.Generate($@"{GlobalVar.SamplePath}/Basic.xml");

            JbAssert.Equal(conf.Find("Item1").Path, "/Basic(Basic)/Function1");
            JbAssert.Equal(conf.Find("Item2").Path, "/Basic(Basic)/Function1");
            JbAssert.Equal(conf.Find("Item3").Path, "/Basic(Basic)/Function2");
            JbAssert.Equal(conf.Find("Item4").Path, "/Basic(Basic)/Function2");
            JbAssert.Equal(conf.Find("Item5").Path, "/Basic(Basic)");

            conf["Item1"] = "Value5";
            JbAssert.Equal(conf.Find("Item1").Path, "/Basic(Basic)/Function1");
        }
示例#7
0
        public void TestConfTree_AddTreeToTree()
        {
            ConfTree tree1 = new ConfTree("Tree1");

            tree1.Add(new ConfItem("Item1", "Value1"));

            ConfTree tree2 = new ConfTree("Tree2");

            tree2.Add(new ConfItem("Item2", "Value2"));

            tree1.Add(tree2);

            Assert.IsTrue(tree1.Find("Item1").Path == "/Tree1");
            Assert.IsTrue(tree1.Find("Tree2").Path == "/Tree1");
            Assert.IsTrue(tree1.Find("Item2").Path == "/Tree1/Tree2");

            Assert.IsTrue(tree1.Find("Item1").Parent.Name == "Tree1");
            Assert.IsTrue(tree1.Find("Tree2").Parent.Name == "Tree1");
            Assert.IsTrue(tree1.Find("Item2").Parent.Name == "Tree2");

            GlobalVar.Log.Debug(tree1.ShowAll());
        }