public void RegisterJumpItem_CloseProgram_ActivateItem_CheckActionExecuted() { try { TestJumpAction jumpAction = new TestJumpAction(); TestProcess.AddApplication("test.exe", p => { using(JumpActionsManager jumpActionsManager = new JumpActionsManager(p, MillisecondsTimeout)) { jumpAction.CommandId = "Run Command!"; jumpAction.Action = () => { p.GetBreakpoint("action").Reach(); }; jumpActionsManager.BeginUpdate(); try { jumpActionsManager.RegisterAction(jumpAction, "/DO=", () => "launcher.exe"); } finally { jumpActionsManager.EndUpdate(); } p.GetBreakpoint("registered").Reach(); p.DoEvents(); } }); TestProcess process = new TestProcess(this, new ProcessStartInfo("test.exe")); process.Start(); process.GetBreakpoint("registered").WaitAndContinue(); process.WaitExit(); new TestProcess(this, jumpAction.StartInfo).Start(); process = TestProcess.WaitProcessStart("test.exe", this); process.GetBreakpoint("registered").WaitAndContinue(); process.GetBreakpoint("action").WaitAndContinue(); } finally { TestProcess.WaitAllProcessesExit(); } }
public void RegisterJumpItem_CloseProgram_ActivateItem_CheckActionExecuted() { try { TestJumpAction jumpAction = new TestJumpAction(); TestProcess.AddApplication("test.exe", p => { using (JumpActionsManager jumpActionsManager = new JumpActionsManager(p, MillisecondsTimeout)) { GC.SuppressFinalize(jumpActionsManager); jumpAction.CommandId = "Run Command!"; jumpAction.Action = () => { p.GetBreakpoint("action").Reach(); }; jumpActionsManager.BeginUpdate(); try { jumpActionsManager.RegisterAction(jumpAction, "/DO=", () => "launcher.exe"); } finally { jumpActionsManager.EndUpdate(); } p.GetBreakpoint("registered").Reach(); p.DoEvents(); } }); TestProcess process = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe"), "13"); process.Start(); process.GetBreakpoint("registered").WaitAndContinue(); process.SendCloseMessage(); process.WaitExit(); new TestProcess(applicationID, this, jumpAction.StartInfo, "14").Start(); process = TestProcess.WaitProcessStart("test.exe", this); process.GetBreakpoint("registered").WaitAndContinue(); process.GetBreakpoint("action").WaitAndContinue(); } finally { TestProcess.WaitAllProcessesExit(); } }
public void SetUp() { applicationID = Guid.NewGuid().ToString(); TestProcess.AddApplication("launcher.exe", p => { using (JumpActionsManagerClient client = new JumpActionsManagerClient(MillisecondsTimeout, p)) { GC.SuppressFinalize(client); client.Run(p.CommandLineArgs.Skip(1).ToArray(), s => new TestProcess(applicationID, this, s, p.ProcessID + " launcher").Start()); } }); }
public void StartTwoInstances_RegisterJumpItem_KillSecondInstance_ActivateItem_CheckActionExecuted() { try { int actionIndex = 0; TestJumpAction[] jumpActions = new TestJumpAction[] { new TestJumpAction(), new TestJumpAction() }; TestProcess.AddApplication("test.exe", p => { JumpActionsManager jumpActionsManager = new JumpActionsManager(p, MillisecondsTimeout); GC.SuppressFinalize(jumpActionsManager); try { TestJumpAction jumpAction = jumpActions[actionIndex++]; jumpAction.CommandId = "Run Command!"; jumpAction.Action = () => { p.GetBreakpoint("action").Reach(); }; jumpActionsManager.BeginUpdate(); try { jumpActionsManager.RegisterAction(jumpAction, "/DO=", () => "launcher.exe"); } finally { jumpActionsManager.EndUpdate(); } p.GetBreakpoint("registered").Reach(); if (!p.CommandLineArgs.Skip(1).Any()) { p.EnvironmentExit(); } p.DoEvents(); } finally { if (!p.DoEnvironmentExit) { jumpActionsManager.Dispose(); } } }); TestProcess process1 = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe", "do_not_kill"), "5"); TestProcess process2 = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe"), "6"); process1.Start(); process2.Start(); process1.GetBreakpoint("registered").Wait(); process2.GetBreakpoint("registered").Wait(); process1.GetBreakpoint("registered").Continue(); process2.GetBreakpoint("registered").Continue(); process2.WaitExit(); new TestProcess(applicationID, this, jumpActions[0].StartInfo, "7").Start(); process1.GetBreakpoint("action").WaitAndContinue(); process1.SendCloseMessage(); process1.WaitExit(); } finally { TestProcess.WaitAllProcessesExit(); } }
public void RegisterJumpItem_StartAnotherInstance_KillAnotherInstance_CloseProgram() { try { int actionIndex = 0; TestJumpAction[] jumpActions = new TestJumpAction[] { new TestJumpAction(), new TestJumpAction() }; TestProcess.AddApplication("test.exe", p => { JumpActionsManager jumpActionsManager = new JumpActionsManager(p, MillisecondsTimeout); GC.SuppressFinalize(jumpActionsManager); try { TestJumpAction jumpAction = jumpActions[actionIndex++]; jumpAction.CommandId = "Run Command!"; jumpAction.Action = () => { p.GetBreakpoint("action").Reach(); }; jumpActionsManager.BeginUpdate(); try { jumpActionsManager.RegisterAction(jumpAction, "/DO=", () => "launcher.exe"); if (p.CommandLineArgs.Skip(1).Any()) { p.EnvironmentExit(); } } finally { if (!p.DoEnvironmentExit) { jumpActionsManager.EndUpdate(); } } p.GetBreakpoint("registered").Reach(); p.DoEvents(); } finally { if (!p.DoEnvironmentExit) { jumpActionsManager.Dispose(); } } }); TestProcess process = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe"), "11"); process.Start(); process.GetBreakpoint("registered").WaitAndContinue(); TestProcess processToKill = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe", "kill"), "12"); processToKill.Start(); processToKill.WaitExit(); process.SendCloseMessage(); process.WaitExit(); } finally { TestProcess.WaitAllProcessesExit(); } }
public void RegisterJumpItem_KillProcess_ActivateItem_CheckActionExecuted() { try { TestJumpAction jumpAction = new TestJumpAction(); TestProcess.AddApplication("test.exe", p => { JumpActionsManager jumpActionsManager = new JumpActionsManager(p, MillisecondsTimeout); GC.SuppressFinalize(jumpActionsManager); try { jumpAction.CommandId = "Run Command!"; jumpAction.Action = () => { p.GetBreakpoint("action").Reach(); }; jumpActionsManager.BeginUpdate(); try { jumpActionsManager.RegisterAction(jumpAction, "/DO=", () => "launcher.exe"); } finally { jumpActionsManager.EndUpdate(); } p.GetBreakpoint("registered").Reach(); if (!p.CommandLineArgs.Skip(1).Any()) { p.EnvironmentExit(); } p.DoEvents(); } finally { if (!p.DoEnvironmentExit) { jumpActionsManager.Dispose(); } } }); TestProcess process = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe"), "9"); process.Start(); process.GetBreakpoint("registered").WaitAndContinue(); process.WaitExit(); new TestProcess(applicationID, this, jumpAction.StartInfo, "10").Start(); process = TestProcess.WaitProcessStart("test.exe", this); process.GetBreakpoint("registered").WaitAndContinue(); process.GetBreakpoint("action").WaitAndContinue(); } finally { TestProcess.WaitAllProcessesExit(); } }
public static TestProcess WaitProcessStart(string applicationName, AsyncTestFixture fixture) { AutoResetEvent wait, cont; lock (runningProcesses) { TestProcess runningProcess = runningProcesses.Keys.Where(p => string.Equals(p.startInfo.FileName, applicationName, StringComparison.Ordinal)).FirstOrDefault(); if (runningProcess != null) { return(runningProcess); } wait = new AutoResetEvent(false); cont = new AutoResetEvent(false); waitStart.Add(applicationName, new Tuple <AutoResetEvent, AutoResetEvent>(wait, cont)); } fixture.WaitOne(wait); TestProcess process = runningProcesses.Keys.Where(p => string.Equals(p.startInfo.FileName, applicationName, StringComparison.Ordinal)).Single(); cont.Set(); return(process); }
public TestBreakpoint(string name, AsyncTestFixture fixture, TestProcess process) : base(fixture) { this.name = name; this.process = process; }
public void TearDown() { TestProcess.ClearApplications(); JumpActionsManagerBase.ClearMemoryMappedFiles(); applicationID = null; }
public void RegisterJumpItem_StartAnotherInstance_KillAnotherInstance_CloseProgram() { try { int actionIndex = 0; TestJumpAction[] jumpActions = new TestJumpAction[] { new TestJumpAction(), new TestJumpAction() }; TestProcess.AddApplication("test.exe", p => { JumpActionsManager jumpActionsManager = new JumpActionsManager(p, MillisecondsTimeout); GC.SuppressFinalize(jumpActionsManager); try { TestJumpAction jumpAction = jumpActions[actionIndex++]; jumpAction.CommandId = "Run Command!"; jumpAction.Action = () => { p.GetBreakpoint("action").Reach(); }; jumpActionsManager.BeginUpdate(); try { jumpActionsManager.RegisterAction(jumpAction, "/DO=", () => "launcher.exe"); if(p.CommandLineArgs.Skip(1).Any()) p.EnvironmentExit(); } finally { if(!p.DoEnvironmentExit) jumpActionsManager.EndUpdate(); } p.GetBreakpoint("registered").Reach(); p.DoEvents(); } finally { if(!p.DoEnvironmentExit) jumpActionsManager.Dispose(); } }); TestProcess process = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe"), "11"); process.Start(); process.GetBreakpoint("registered").WaitAndContinue(); TestProcess processToKill = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe", "kill"), "12"); processToKill.Start(); processToKill.WaitExit(); process.SendCloseMessage(); process.WaitExit(); } finally { TestProcess.WaitAllProcessesExit(); } }
public void StartTwoInstances_RegisterJumpItem_KillSecondInstance_ActivateItem_CheckActionExecuted() { try { int actionIndex = 0; TestJumpAction[] jumpActions = new TestJumpAction[] { new TestJumpAction(), new TestJumpAction() }; TestProcess.AddApplication("test.exe", p => { JumpActionsManager jumpActionsManager = new JumpActionsManager(p, MillisecondsTimeout); GC.SuppressFinalize(jumpActionsManager); try { TestJumpAction jumpAction = jumpActions[actionIndex++]; jumpAction.CommandId = "Run Command!"; jumpAction.Action = () => { p.GetBreakpoint("action").Reach(); }; jumpActionsManager.BeginUpdate(); try { jumpActionsManager.RegisterAction(jumpAction, "/DO=", () => "launcher.exe"); } finally { jumpActionsManager.EndUpdate(); } p.GetBreakpoint("registered").Reach(); if(!p.CommandLineArgs.Skip(1).Any()) p.EnvironmentExit(); p.DoEvents(); } finally { if(!p.DoEnvironmentExit) jumpActionsManager.Dispose(); } }); TestProcess process1 = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe", "do_not_kill"), "5"); TestProcess process2 = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe"), "6"); process1.Start(); process2.Start(); process1.GetBreakpoint("registered").Wait(); process2.GetBreakpoint("registered").Wait(); process1.GetBreakpoint("registered").Continue(); process2.GetBreakpoint("registered").Continue(); process2.WaitExit(); new TestProcess(applicationID, this, jumpActions[0].StartInfo, "7").Start(); process1.GetBreakpoint("action").WaitAndContinue(); process1.SendCloseMessage(); process1.WaitExit(); } finally { TestProcess.WaitAllProcessesExit(); } }
public void RegisterJumpItem_KillProcess_ActivateItem_CheckActionExecuted() { try { TestJumpAction jumpAction = new TestJumpAction(); TestProcess.AddApplication("test.exe", p => { JumpActionsManager jumpActionsManager = new JumpActionsManager(p, MillisecondsTimeout); GC.SuppressFinalize(jumpActionsManager); try { jumpAction.CommandId = "Run Command!"; jumpAction.Action = () => { p.GetBreakpoint("action").Reach(); }; jumpActionsManager.BeginUpdate(); try { jumpActionsManager.RegisterAction(jumpAction, "/DO=", () => "launcher.exe"); } finally { jumpActionsManager.EndUpdate(); } p.GetBreakpoint("registered").Reach(); if(!p.CommandLineArgs.Skip(1).Any()) p.EnvironmentExit(); p.DoEvents(); } finally { if(!p.DoEnvironmentExit) jumpActionsManager.Dispose(); } }); TestProcess process = new TestProcess(applicationID, this, new ProcessStartInfo("test.exe"), "9"); process.Start(); process.GetBreakpoint("registered").WaitAndContinue(); process.WaitExit(); new TestProcess(applicationID, this, jumpAction.StartInfo, "10").Start(); process = TestProcess.WaitProcessStart("test.exe", this); process.GetBreakpoint("registered").WaitAndContinue(); process.GetBreakpoint("action").WaitAndContinue(); } finally { TestProcess.WaitAllProcessesExit(); } }