public static void Test_SubProcess_async()
        {
            SubProcess sp   = new SubProcess(echoArgs, "--exit", "2");
            Task <int> task = sp.WaitAsync();

            task.Wait();
            Assert.AreEqual(2, task.Result);
        }
        public static void Test_SubProcess_no_timeout_async()
        {
            SubProcess sp = new SubProcess(echoArgs, "a")
            {
                Timeout = 99999
            };
            Task <int> task = sp.WaitAsync();

            task.Wait();
        }
        public static void Test_SubProcess_async_output_redirect()
        {
            MemoryStream ms = new MemoryStream();
            SubProcess   sp = new SubProcess(echoArgs, "Hello", "--exit", "2")
            {
                Out = ms
            };
            Task <int> task = sp.WaitAsync();

            task.Wait();
            Assert.AreEqual(2, task.Result);
            byte[] bytes = ms.GetBuffer();
            ms = new MemoryStream(bytes);
            StreamReader tr = new StreamReader(ms);

            Assert.AreEqual("Hello", tr.ReadLine());
        }
 public static void Test_SubProcess_timeout_async()
 {
     using (SubProcess sp = new SubProcess(echoArgs, "--wait", "100")
     {
         Timeout = 0.1
     })
     {
         try
         {
             sp.WaitAsync().Wait();
             Assert.Fail("Did not throw on timeout");
         }
         catch (AggregateException ae)
         {
             Assert.AreEqual(1, ae.InnerExceptions.Count);
             Assert.IsTrue(ae.InnerExceptions[0] is SubProcess.TimeoutException);
         }
     }
 }