public void StartAsync_ReceivesFaultedRequestExecutedResult_ThrowsExceptionInRequestExecutedResult()
        {
            var messageDispatcher       = TestableMessageDispatcher.Create();
            var cancellationTokenSource = new CancellationTokenSource();

            messageDispatcher.DispatchMessagesBufferBlock.Post(new RequestExecutedChannelMessage(new RequestExecutedResult(new InvalidOperationException("exception message"))));
            messageDispatcher.DispatchMessagesBufferBlock.Complete();

            Assert.Throws <InvalidOperationException>(() => messageDispatcher.StartAsync(cancellationTokenSource.Token).GetAwaiter().GetResult());
        }
        public void StartAsync_ReceivesdRequestExecutedResult_CallsChannelWriteOnTheResponse()
        {
            var messageDispatcher       = TestableMessageDispatcher.Create();
            var cancellationTokenSource = new CancellationTokenSource();
            var response = new Response
            {
                Id = Guid.NewGuid()
            };

            messageDispatcher.DispatchMessagesBufferBlock.Post(new RequestExecutedChannelMessage(new RequestExecutedResult(response)));
            messageDispatcher.DispatchMessagesBufferBlock.Complete();

            messageDispatcher.StartAsync(cancellationTokenSource.Token).Wait();

            messageDispatcher.ChannelMock.Verify(c => c.Write(response), Times.Once);
        }