public void TestConfTree_Clone_Modify_Save() { ConfTree conf1 = Builder.Generate(new Dictionary <string, string> { { "Item1", "Value1" }, { "Item2", "Value2" }, }, "DictionaryConf"); Builder.Xml.Save(conf1, $"{GlobalVar.ResultPath}/Conf.xml"); GlobalVar.Log.Debug(conf1.ShowAll()); ConfTree conf2 = conf1.Clone("new") as ConfTree; Builder.Xml.Save(conf2 as ConfTree); conf1["Item1"] = "Value3"; Builder.Xml.Save(conf1 as ConfTree); Debug.WriteLine(conf2.ToString()); conf2["Item2"] = "Value4"; Builder.Xml.Save(conf2 as ConfTree); ConfTree readback = Builder.Xml.Generate($"{GlobalVar.ResultPath}/Conf.xml"); Debug.WriteLine(readback.ToString()); JbAssert.Equal(readback["Default:Item1"], "Value3"); JbAssert.Equal(readback["Default:Item2"], "Value2"); JbAssert.Equal(readback["new:Item1"], "Value1"); JbAssert.Equal(readback["new:Item2"], "Value4"); }
public void TestConfTree_Clone_SaveToDiffFile() { ConfTree conf1 = Builder.Generate(new Dictionary <string, string> { { "Item1", "Value1" }, { "Item2", "Value2" }, }, "DictionaryConf"); Assert.IsTrue(conf1.XmlDoc == null); Builder.Xml.Save(conf1, $"{GlobalVar.ResultPath}/Conf1.xml"); JbAssert.PathEqual((conf1.XmlDoc as XmlDocument).BaseURI, $"file:///{GlobalVar.ResultPath}/Conf1.xml"); var conf2 = conf1.Clone("new"); Debug.WriteLine(conf2.ToString()); Assert.IsTrue((conf2 as ConfTree).XmlDoc == null); Builder.Xml.Save(conf2 as ConfTree, $"{GlobalVar.ResultPath}/Conf2.xml"); JbAssert.PathEqual(((conf2 as ConfTree).XmlDoc as XmlDocument).BaseURI, $"file:///{GlobalVar.ResultPath}/Conf2.xml"); ConfTree conf = new ConfTree("DictionaryConf"); conf.Add(conf1); conf.Add(conf2); Debug.WriteLine(conf.ToString()); Builder.Xml.Save(conf as ConfTree, $"{GlobalVar.ResultPath}/Conf.xml"); JbAssert.PathEqual(((conf as ConfTree).XmlDoc as XmlDocument).BaseURI, $"file:///{GlobalVar.ResultPath}/Conf.xml"); var conf4 = conf.Clone("conf4"); ConfTree super = new ConfTree("SuperConf"); super.Add(conf); super.Add(conf4); Builder.Xml.Save(super, $"{GlobalVar.ResultPath}/Super.xml"); JbAssert.PathEqual(((super as ConfTree).XmlDoc as XmlDocument).BaseURI, $"file:///{GlobalVar.ResultPath}/Super.xml"); }