public WaitForProcessExit()
            {
                ExpectedResult   = new WaitForProcessExitResult();
                ExpectedResponse = new WaitForProcessExitResponse(JToken.FromObject(1), ExpectedResult);

                MessagingClient.SendMessageAsync <WaitForProcessExitRequest, WaitForProcessExitResponse>(null)
                .ReturnsForAnyArgs(GetCompletedTask(ExpectedResponse));
            }
        public Task <WaitForProcessExitResult> ExecuteAsync(WaitForProcessExitParams p)
        {
            var process = processTracker.GetProcessByKey(p.key);

            if (process == null)
            {
                throw new Exception(String.Format("A process with key '{0}' is not being tracked.", p.key));
            }

            var success = process.WaitForExit(p.timeout);

            var result = new WaitForProcessExitResult
            {
                exited   = success,
                exitCode = success ? process.ExitCode : 0,
            };

            if (result.exited)
            {
                processTracker.RemoveProcess(p.key);
            }

            return(Task.FromResult(result));
        }