public void can_get_exit_code_from_process() { using (var subject = new ProcessHost("./ExampleNoninteractiveProcess.exe", Directory.GetCurrentDirectory())) { subject.Start("return 1729"); Assert.That(subject.WaitForExit(one_second), "process did not exit"); var code = subject.ExitCode(); Assert.That(code, Is.EqualTo(1729)); } }
public void can_wait_for_process_and_kill_if_required() { using (var subject = new ProcessHost("./ExampleNoninteractiveProcess.exe", Directory.GetCurrentDirectory())) { subject.Start("wait"); var ended = subject.WaitForExit(one_second); Assert.That(ended, Is.False, "Ended"); Assert.That(subject.IsAlive(), Is.True, "Alive"); subject.Kill(); var endedAfterKill = subject.WaitForExit(one_second); Assert.That(endedAfterKill, Is.True, "ended after kill"); Assert.That(subject.IsAlive(), Is.False, "Alive after kill"); Assert.That(subject.ExitCode(), Is.EqualTo(127), "standard killed code"); } }