public IEnumerator CanExecuteAndRestartProcess()
        {
            using (var test = StartTest())
                using (var processServer = new TestProcessServer(test.TaskManager, test.Environment,
                                                                 test.Configuration))
                {
                    processServer.ConnectSync();

                    var task = new ProcessTask <string>(test.TaskManager,
                                                        test.ProcessManager.DefaultProcessEnvironment,
                                                        TestApp, "-s 100", new StringOutputProcessor())
                    {
                        Affinity = TaskAffinity.None
                    };
                    task.Configure(processServer.ProcessManager, new ProcessOptions(MonitorOptions.KeepAlive, true));

                    var restartCount = 0;

                    var restarted = new TaskCompletionSource <ProcessRestartReason>();
                    processServer.ProcessManager.OnProcessRestart += (sender, args) => {
                        restartCount++;
                        if (restartCount == 2)
                        {
                            restarted.TrySetResult(args.Reason);
                        }
                    };

                    task.Start();

                    var timeout = Task.Delay(4000);
                    var wait    = Task.WhenAny(restarted.Task, timeout);
                    foreach (var frame in WaitForCompletion(wait))
                    {
                        yield return(frame);
                    }

                    Assert.True(wait.Result != timeout, "Restart did not happen on time");

                    task.Detach();

                    Assert.AreEqual(ProcessRestartReason.KeepAlive, restarted.Task.Result);
                }
        }