public void HasChangesTest() { LaunchGroup group = new LaunchGroup(); LaunchGroup childGroup = new LaunchGroup(); Launcher childLauncher = new Launcher(); Assert.IsFalse(group.HasChanges); group.Name = "a"; Assert.IsTrue(group.HasChanges, "Changing Name should cause HasChanges to be true"); group.ClearAllHasChanges(); group.EnvironmentVariables.Add(new EnvironmentVariable("A", "A")); Assert.IsTrue(group.HasChanges, "New environment variables should cause HasChanges to be true"); group.ClearAllHasChanges(); group.EnvironmentVariables["A"] = "B"; Assert.IsTrue(group.HasChanges, "Updating environment variables should cause HasChanges to be true"); group.ClearAllHasChanges(); group.Groups.Add(childGroup); Assert.IsTrue(group.HasChanges, "New child groups should cause HasChages to be true"); group.ClearAllHasChanges(); childGroup.Name = "a"; Assert.IsTrue(group.HasChanges, "Changes to child groups should cause HasChanges to be true"); group.ClearAllHasChanges(); group.Launchers.Add(childLauncher); Assert.IsTrue(group.HasChanges, "New child launchers should cause HasChanges to be true"); group.ClearAllHasChanges(); childLauncher.Name = "A"; Assert.IsTrue(group.HasChanges, "Changes to child launchers should cause HasChanges to be true"); }
/// <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 ClearAllHasChangesTest() { var group = new LaunchGroup(null, new[] { new LaunchGroup(null, new[] { new LaunchGroup { HasChanges = true }, }, new[] { new Launcher { HasChanges = true }, }) { HasChanges = true }, }, new[] { new Launcher { HasChanges = true }, }) { HasChanges = true }; Assert.IsTrue(group.HasChanges, "All Groups and Launchers should have changes"); Assert.IsTrue(group.Groups[0].HasChanges, "All Groups and Launchers should have changes"); Assert.IsTrue(group.Groups[0].Groups[0].HasChanges, "All Groups and Launchers should have changes"); Assert.IsTrue(group.Groups[0].Launchers[0].HasChanges, "All Groups and Launchers should have changes"); Assert.IsTrue(group.Launchers[0].HasChanges, "All Groups and Launchers should have changes"); group.ClearAllHasChanges(); Assert.IsFalse(group.HasChanges, "All Groups and Launchers should not have changes"); Assert.IsFalse(group.Groups[0].HasChanges, "All Groups and Launchers should not have changes"); Assert.IsFalse(group.Groups[0].Groups[0].HasChanges, "All Groups and Launchers should not have changes"); Assert.IsFalse(group.Groups[0].Launchers[0].HasChanges, "All Groups and Launchers should not have changes"); Assert.IsFalse(group.Launchers[0].HasChanges, "All Groups and Launchers should not have changes"); }
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"); }
public void AggregateEnvironmentVariablesTest() { var launcher = new Launcher(); LaunchGroup group = new LaunchGroup(null, new[] { new LaunchGroup(null, null, new[] { launcher }), }); group.EnvironmentVariables.UpdateWith( new EnvironmentVariable("A", "A"), new EnvironmentVariable("B", "B"), new EnvironmentVariable("D", "D")); group.Groups[0].EnvironmentVariables.UpdateWith( new EnvironmentVariable("C", "C"), new EnvironmentVariable("B", "B2")); launcher.EnvironmentVariables.UpdateWith( new EnvironmentVariable("D", "D2"), new EnvironmentVariable("E", "E")); var envVars = launcher.AggregateEnvironmentVariables(); Assert.That(envVars, Contains.Item(new EnvironmentVariable("A", "A"))); Assert.That(envVars, Contains.Item(new EnvironmentVariable("B", "B2"))); Assert.That(envVars, Contains.Item(new EnvironmentVariable("C", "C"))); Assert.That(envVars, Contains.Item(new EnvironmentVariable("D", "D2"))); Assert.That(envVars, Contains.Item(new EnvironmentVariable("E", "E"))); }