public void WaitForExit_completes_after_exit() { ProcessExitStub subject = new ProcessExitStub(); ProcessExitWatcher process = new ProcessExitWatcher(subject); Task task = process.WaitForExitAsync(CancellationToken.None); Assert.False(task.IsCompleted); subject.RaiseExited(); Assert.Equal(TaskStatus.RanToCompletion, task.Status); }
public void Race_with_exit_and_subscribe_does_not_cause_errors() { ProcessExitStub subject = new ProcessExitStub(); subject.Subscribed += delegate(object sender, EventArgs e) { subject.RaiseExited(); subject.HasExited = true; }; ProcessExitWatcher process = new ProcessExitWatcher(subject); Task task = process.WaitForExitAsync(CancellationToken.None); Assert.Equal(TaskStatus.RanToCompletion, task.Status); }