//user can clear previous saved data by deleting the file from the config location public void Load() { var storageProxy = new pickle.Pickler(GetExePath() + _configProxyPath); var storagePrevWsdl = new pickle.Pickler(GetExePath() + _configPrevWsdlPath); var storageTimeout = new pickle.Pickler(GetExePath() + _configTimeoutPath); var storagePrevUrl = new pickle.Pickler(GetExePath() + _configPrevUrlPath); var storageUpdate = new pickle.Pickler(GetExePath() + _configUpdatePath); var storageStartupWsdls = new pickle.Pickler(GetExePath() + _configStartupWsdlsPath); ConfigTimeout = new model.Config.CallTimeout(); ConfigProxy = new model.Config.Proxy(); ConfigPrevWsdls = new model.Config.PrevWsdls(AppConfig.Instance.MaxPrevWsdls); ConfigPrevUrls = new model.Config.PrevUrls(AppConfig.Instance.MaxPrevUrls); ConfigUpdate = new model.Config.Update(); ConfigStartupWsdls = new model.Config.StartupWsdls(AppConfig.Instance.MaxStartupWsdls); storageTimeout.Load(ConfigTimeout); storageProxy.Load(ConfigProxy); if (Mode == ProjectMode.MultipleWsdl) { storageUpdate.Load(ConfigUpdate); storagePrevWsdl.Load(ConfigPrevWsdls); storagePrevUrl.Load(ConfigPrevUrls); storageStartupWsdls.Load(ConfigStartupWsdls); } }
//Test that if the data file does not exist we are returned the proxy with defaults public void TestDeserializeNoFile() { string testDataPath = _testDataDirectory + Path.DirectorySeparatorChar + @"non_exist_file.data"; //file should not exist at the beginning of the test Assert.IsFalse(File.Exists(testDataPath)); var storageProxy = new pickle.Pickler(testDataPath); var configProxy = new model.Config.Proxy(); storageProxy.Load(configProxy); Assert.AreEqual(configProxy.Port, 8888); Assert.AreEqual(configProxy.Host, "127.0.0.1"); //the file is created on load Assert.IsTrue(File.Exists(testDataPath)); //cleanup File.Delete(testDataPath); }
//Test that if the data is modified then it is corretly saved and read from disk //tests read and write public void TestSerializeDeserialize() { string testDataPath = _testDataDirectory + Path.DirectorySeparatorChar + @"proxy-serialize-deserialize.txt"; Assert.IsTrue(File.Exists(testDataPath)); //first test that data is correcly read in from disk var storageProxy = new pickle.Pickler(testDataPath); var configProxy = new model.Config.Proxy(); storageProxy.Load(configProxy); Assert.AreEqual(configProxy.Port, 1234); Assert.AreEqual(configProxy.Host, "123.4.5.6"); Assert.AreEqual(configProxy.ProxyType, Drexyia.WebSvc.Model.Proxy.EProxyType.Disabled); Assert.AreEqual(configProxy.Modified, false); //modify data and serialize back to file configProxy.Port = 5678; configProxy.Host = "111.2.3.4"; configProxy.ProxyType = Drexyia.WebSvc.Model.Proxy.EProxyType.Enabled; storageProxy.Save(configProxy); //read in the data again and check the values storageProxy = new pickle.Pickler(testDataPath); configProxy = new model.Config.Proxy(); storageProxy.Load(configProxy); Assert.AreEqual(configProxy.Port, 5678); Assert.AreEqual(configProxy.Host, "111.2.3.4"); Assert.AreEqual(configProxy.ProxyType, Drexyia.WebSvc.Model.Proxy.EProxyType.Enabled); Assert.AreEqual(configProxy.Modified, false); //set the settings back to initial so that tests can run again configProxy.Port = 1234; configProxy.Host = "123.4.5.6"; configProxy.ProxyType = Drexyia.WebSvc.Model.Proxy.EProxyType.Disabled; storageProxy.Save(configProxy); }
//user can clear previous saved data by deleting the file from the config location public void Load() { var storageProxy = new pickle.Pickler(GetExePath() + _configProxyPath); var storagePrevWsdl = new pickle.Pickler(GetExePath() + _configPrevWsdlPath); var storageTimeout = new pickle.Pickler(GetExePath() + _configTimeoutPath); var storagePrevUrl = new pickle.Pickler(GetExePath() + _configPrevUrlPath); var storageUpdate = new pickle.Pickler(GetExePath() + _configUpdatePath); var storageStartupWsdls = new pickle.Pickler(GetExePath() + _configStartupWsdlsPath); ConfigTimeout = new model.Config.CallTimeout(); ConfigProxy = new model.Config.Proxy(); ConfigPrevWsdls = new model.Config.PrevWsdls(AppConfig.Instance.MaxPrevWsdls); ConfigPrevUrls = new model.Config.PrevUrls(AppConfig.Instance.MaxPrevUrls); ConfigUpdate = new model.Config.Update(); ConfigStartupWsdls = new model.Config.StartupWsdls(AppConfig.Instance.MaxStartupWsdls); storageTimeout.Load(ConfigTimeout); storageProxy.Load(ConfigProxy); if (Mode == ProjectMode.MultipleWsdl) { storageUpdate.Load(ConfigUpdate); storagePrevWsdl.Load(ConfigPrevWsdls); storagePrevUrl.Load(ConfigPrevUrls); storageStartupWsdls.Load(ConfigStartupWsdls); } }