public void SaveRegisteredServersTest_GoodSave() { RegisteredServers regServers = new RegisteredServers(); regServers.ServerGroup = new ServerGroup[2]; regServers.ServerGroup[0] = new ServerGroup() { Name = "Test" }; regServers.ServerGroup[1] = new ServerGroup() { Name = "Test2" }; bool expected = true; bool actual; RegisteredServerHelper.RegisteredServerFileName = Path.GetTempFileName(); actual = RegisteredServerHelper.SaveRegisteredServers(regServers); Assert.AreEqual(expected, actual); Assert.IsTrue(File.Exists(RegisteredServerHelper.RegisteredServerFileName)); string contents = File.ReadAllText(RegisteredServerHelper.RegisteredServerFileName); Regex regexServer = new Regex("ServerGroup", RegexOptions.None); Assert.IsTrue(regexServer.Matches(contents).Count == 2); File.Delete(RegisteredServerHelper.RegisteredServerFileName); }
private void UpdateRegisteredServersList() { RegisteredServers tmpRegServers = new RegisteredServers(); List <ServerGroup> grps = new List <ServerGroup>(); foreach (TreeNode grpNode in this.treeView1.Nodes[0].Nodes) { if (grpNode.Tag is ServerGroup) { ServerGroup tmpGrp = (ServerGroup)grpNode.Tag; List <RegServer> srvs = new List <RegServer>(); foreach (TreeNode srvNode in grpNode.Nodes) { if (srvNode.Tag is RegServer) { srvs.Add((RegServer)srvNode.Tag); } } tmpGrp.RegServer = srvs.ToArray(); grps.Add(tmpGrp); } } tmpRegServers.ServerGroup = grps.ToArray(); RegisteredServerHelper.SaveRegisteredServers(tmpRegServers); }
public void SaveRegisteredServersTest_NullRegisteredServersSave() { RegisteredServers regServers = null; bool expected = false; bool actual; RegisteredServerHelper.RegisteredServerFileName = Path.GetTempFileName(); actual = RegisteredServerHelper.SaveRegisteredServers(regServers); Assert.AreEqual(expected, actual); }