public void WaitForExitNotStarted()
        {
            // If: I wait for exit on the JSON RPC host without starting it
            // Then: I should get an exception
            var jh = new JsonRpcHost(GetChannelBase(null, null).Object);

            Assert.Throws <InvalidOperationException>(() => jh.WaitForExit());
        }
        public async Task WaitForExit()
        {
            // Setup: Create json rpc host and start it
            var mr = new Mock <MessageReader>(Stream.Null, null);
            var mw = new Mock <MessageWriter>(Stream.Null);
            var jh = new JsonRpcHost(GetChannelBase(mr.Object, mw.Object).Object);

            jh.Start();

            // If: I wait for JSON RPC host to exit and stop it
            // NOTE: We are wrapping this execution in a task to make sure we can properly stop the host
            Task waitForExit = Task.Run(() => { jh.WaitForExit(); });

            jh.Stop();

            // Then: The host should be stopped
            await waitForExit.WithTimeout(TimeSpan.FromSeconds(1));
        }