public void UserConfigWriteTest() { UserConfigWriter.m_TestUserConfigName = Path.GetTempPath() + "user.config"; AppConfigWriter.m_TestAppConfigName = Path.GetTempPath() + "app.config"; if (File.Exists(UserConfigWriter.m_TestUserConfigName)) { File.Delete(UserConfigWriter.m_TestUserConfigName); } ConfigWriter config = new ConfigWriter(); config.Read(UserConfigWriter.m_TestUserConfigName); Assert.AreEqual("", config.GetItem("PromtReasonForChange")); //UserConfigWriter.Instance.SetItem("PromtReasonForChange", "true"); //UserConfigWriter.Instance.SetItem("SomeItem", "true"); //UserConfigWriter.Instance.Save(); //config.Read(UserConfigWriter.m_TestUserConfigName); //Assert.AreEqual("true", config.GetItem("PromtReasonForChange")); //Assert.AreEqual("", config.GetItem("SomeItem")); var target = UserConfigWriter.CreateConfigWriter(); target.SetItem("PromtReasonForChange", "false"); target.SetItem("SomeItem", "false"); target.Save(); config.Read(UserConfigWriter.m_TestUserConfigName); Assert.AreEqual("false", config.GetItem("PromtReasonForChange")); Assert.AreEqual("", config.GetItem("SomeItem")); }
public void AppConfigWriteTest() { UserConfigWriter.m_TestUserConfigName = Path.GetTempPath() + "user_v6.config"; AppConfigWriter.m_TestAppConfigName = Path.GetTempPath() + "app_v6.config"; if (File.Exists(AppConfigWriter.m_TestAppConfigName)) { File.Delete(AppConfigWriter.m_TestAppConfigName); } var config = new ConfigWriter(); config.Read(AppConfigWriter.m_TestAppConfigName); Assert.AreEqual("", config.GetItem("DocumentPrinter")); string expected = "test printer"; //Assert.AreEqual(AppConfigWriter.Instance.FileName, AppConfigWriter.m_TestAppConfigName); //AppConfigWriter.Instance.SetItem("DocumentPrinter", expected); //AppConfigWriter.Instance.SetItem("SomeItem", "true"); //AppConfigWriter.Instance.Save(); //config.Read(AppConfigWriter.m_TestAppConfigName); //Assert.AreEqual(expected, config.GetItem("DocumentPrinter")); //Assert.AreEqual("", config.GetItem("SomeItem")); ConfigWriter target = AppConfigWriter.CreateConfigWriter(); target.SetItem("DocumentPrinter", expected); target.SetItem("SomeItem", "false"); target.Save(); config.Read(AppConfigWriter.m_TestAppConfigName); Assert.AreEqual(expected, config.GetItem("DocumentPrinter")); Assert.AreEqual("", config.GetItem("SomeItem")); }
private void LoadConfig(string configName) { m_config = ConfigWriter.Instance; if (string.IsNullOrEmpty(configName)) { configName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), Config.GeneralConfigName); } m_config.Read(File.Exists(configName) ? configName : Config.DefaultGeneralConfigPath); lbConfigFileName.Text = m_config.FileName; }