/// <summary> /// Opens the given file as the root node. /// </summary> /// <param name = "file">The file to open.</param> private void _Open(string file) { if (File.Exists(file)) { Root = new LaunchGroupViewModel(LaunchGroup.LoadFrom(file)); Settings.Default.CurrentFile = file; } else { Root = new LaunchGroupViewModel(new LaunchGroup()); } }
public void SaveLoadTest() { var tempFile = Path.GetTempFileName(); var launchGroup = new LaunchGroup { Name = "Root", EnvironmentVariables = { { "Var1", "Val1" }, { "Var2", "Val2" } } }; launchGroup.Groups.Add(new LaunchGroup { Name = "LG1", EnvironmentVariables = { { "Var3", "Val3" } } }); launchGroup.Launchers.Add(new Launcher { Arguments = "abc", File = "somefile", Name = "test", WorkingDirectory = "aaaa", EnvironmentVariables = { { "Var4", "Val4" } } }); launchGroup.SaveTo(tempFile); var newGroup = LaunchGroup.LoadFrom(tempFile); Assert.AreNotSame(launchGroup, newGroup, "LoadFrom should have created a new group"); Assert.AreEqual(launchGroup, newGroup, "LoadFrom should have loaded a group equal to the saved one"); }