コード例 #1
0
        public void TestKill()
        {
            Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));

            using (AssemblyRunner runner = new AssemblyRunner(Exe))
            {
                ManualResetEvent gotExit = new ManualResetEvent(false);
                runner.ProcessExited += delegate(Object o, ProcessExitedEventArgs e) { gotExit.Set(); };
                Assert.IsFalse(runner.IsRunning);
                runner.Kill(); // always safe to call

                runner.Start("-wait");
                Assert.IsTrue(runner.IsRunning);

                try //make sure we can't start twice.
                {
                    runner.Start();
                    Assert.Fail();
                }
                catch (InvalidOperationException)
                { }

                Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
                runner.Kill();
                Assert.IsFalse(runner.IsRunning);
                Assert.IsTrue(gotExit.WaitOne(30000, false));
            }
        }
コード例 #2
0
 public void TestStandardInputFail()
 {
     using (IRunner runner = new AssemblyRunner(Exe))
     {
         runner.Start("-wait");
         runner.StandardInput.WriteLine();
     }
 }
コード例 #3
0
 public void TestUnhandledExceptionWaitForExit()
 {
     using (IRunner runner = new AssemblyRunner(Exe))
     {
         runner.Start("-throw", "System.ArgumentOutOfRangeException");
         runner.WaitForExit();
         Assert.Fail();
     }
 }