public void TestModifyItem() { string testDataPath = _testDataDirectory + Path.DirectorySeparatorChar + @"non_exist_file.data"; var storage = new pickle.Pickler(testDataPath); var config = new model.Config.PrevWsdls(5); storage.Load(config); //Test that each wsdl is added to the start of the list config.Add("A"); config.Add("B"); config.Add("C"); config.Add("D"); config.Add("E"); Assert.AreEqual(config.WsdlList[0], "E"); Assert.AreEqual(config.WsdlList[4], "A"); Assert.AreEqual(config.WsdlList.Count(), 5); //Test that if an item is added to the list that exceeds the number of items the last item from the list is removed config.Add("F"); Assert.AreEqual(config.WsdlList[0], "F"); Assert.AreEqual(config.WsdlList[4], "B"); Assert.AreEqual(config.WsdlList.Count(), 5); //cleanup File.Delete(testDataPath); }
//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 is modified then it is corretly saved and read from disk //tests read and write public void TestSerializeDeserialize() { string testDataPath = _testDataDirectory + Path.DirectorySeparatorChar + @"prevwsdl-serialize-deserialize.txt"; Assert.IsTrue(File.Exists(testDataPath)); //first read in and check data var storage = new pickle.Pickler(testDataPath); var config = new model.Config.PrevWsdls(5); storage.Load(config); Assert.AreEqual(config.WsdlList[0], @"http://*****:*****@"file://C:\service2.wsdl"); Assert.AreEqual(config.WsdlList[2], @"http://*****:*****@"file://C:\service4.wsdl"); Assert.AreEqual(config.WsdlList[4], @"http://*****:*****@"http://localhost:5555/service5.svc?wsdl"); config.Add(@"file://*****:*****@"http://localhost:3333/service3.svc?wsdl"); config.Add(@"file://*****:*****@"http://localhost:1111/service1.svc?wsdl"); storage.Save(config); }
//Test that if the amount of max items is modified then the number of prevwsdls is reduced public void TestModifyItemMaxItemsChanged() { string testDataPath = _testDataDirectory + Path.DirectorySeparatorChar + @"prevwsdl-serialize-deserialize.txt"; Assert.IsTrue(File.Exists(testDataPath)); //first read in and check data var storage = new pickle.Pickler(testDataPath); var config = new model.Config.PrevWsdls(2); storage.Load(config); Assert.AreEqual(config.WsdlList.Count(), 2); Assert.AreEqual(config.WsdlList[0], @"http://*****:*****@"file://C:\service2.wsdl"); }
public void Save() { var storageProxy = new pickle.Pickler(GetExePath() + _configProxyPath); var storageTimeout = new pickle.Pickler(GetExePath() + _configTimeoutPath); var storagePrevWsdl = new pickle.Pickler(GetExePath() + _configPrevWsdlPath); var storagePrevUrl = new pickle.Pickler(GetExePath() + _configPrevUrlPath); var storageUpdate = new pickle.Pickler(GetExePath() + _configUpdatePath); var storageStartupWsdls = new pickle.Pickler(GetExePath() + _configStartupWsdlsPath); storageTimeout.Save(ConfigTimeout); storageProxy.Save(ConfigProxy); if (Mode == ProjectMode.MultipleWsdl) { storagePrevWsdl.Save(ConfigPrevWsdls); storagePrevUrl.Save(ConfigPrevUrls); storageUpdate.Save(ConfigUpdate); storageStartupWsdls.Save(ConfigStartupWsdls); } }
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 storage = new pickle.Pickler(testDataPath); var config = new model.Config.PrevWsdls(0); storage.Load(config); Assert.AreEqual(config.WsdlList.Count(), 0); //the file is created on load Assert.IsTrue(File.Exists(testDataPath)); //cleanup File.Delete(testDataPath); }
//Test that if the data file does not exist we are returned an object with an empty list of wsdls 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 storage = new pickle.Pickler(testDataPath); var config = new model.Config.PrevWsdls(0); storage.Load(config); Assert.AreEqual(config.WsdlList.Count(), 0); //the file is created on load Assert.IsTrue(File.Exists(testDataPath)); //cleanup File.Delete(testDataPath); }
//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); }
public void TestModifyItemMaxItemsChanged() { string testDataPath = _testDataDirectory + Path.DirectorySeparatorChar + @"prevwsdl-serialize-deserialize.txt"; Assert.IsTrue(File.Exists(testDataPath)); //first read in and check data var storage = new pickle.Pickler(testDataPath); var config = new model.Config.PrevWsdls(2); storage.Load(config); Assert.AreEqual(config.WsdlList.Count(), 2); Assert.AreEqual(config.WsdlList[0], @"http://*****:*****@"file://C:\service2.wsdl"); }
public void TestSerializeDeserialize() { string testDataPath = _testDataDirectory + Path.DirectorySeparatorChar + @"prevwsdl-serialize-deserialize.txt"; Assert.IsTrue(File.Exists(testDataPath)); //first read in and check data var storage = new pickle.Pickler(testDataPath); var config = new model.Config.PrevWsdls(5); storage.Load(config); Assert.AreEqual(config.WsdlList[0], @"http://*****:*****@"file://C:\service2.wsdl"); Assert.AreEqual(config.WsdlList[2], @"http://*****:*****@"file://C:\service4.wsdl"); Assert.AreEqual(config.WsdlList[4], @"http://*****:*****@"http://localhost:5555/service5.svc?wsdl"); config.Add(@"file://*****:*****@"http://localhost:3333/service3.svc?wsdl"); config.Add(@"file://*****:*****@"http://localhost:1111/service1.svc?wsdl"); storage.Save(config); }