public async Task Should_abandon_message_on_errors()
        {
            //arrange
            var nextProcessor       = new Mock <IMessageProcessor>();
            var messageStateHandler = new Mock <IMessageStateHandler <TestCommand> >();

            nextProcessor.Setup(x => x.ProcessAsync(messageStateHandler.Object, CancellationToken.None))
            .Throws <Exception>();
            var logger     = new Mock <ILog>();
            var middleware = new ErrorHandlingMiddleware(logger.Object);
            //act
            await middleware.ProcessAsync(messageStateHandler.Object, Mock.Of <IPipelineInformation>(), nextProcessor.Object, CancellationToken.None);

            //assert
            messageStateHandler.Verify(x => x.AbandonByErrorAsync(It.IsAny <Exception>()), Times.Once);
        }
        public async Task Should_log_errors()
        {
            //arrange
            var nextProcessor       = new Mock <IMessageProcessor>();
            var messageStateHandler = new Mock <IMessageStateHandler <TestCommand> >();

            nextProcessor.Setup(x => x.ProcessAsync(messageStateHandler.Object, CancellationToken.None))
            .Throws <Exception>();
            var logger     = new Mock <ILog>();
            var middleware = new ErrorHandlingMiddleware(logger.Object);
            //act
            await middleware.ProcessAsync(messageStateHandler.Object, nextProcessor.Object, CancellationToken.None);

            //assert
            logger.Verify(x => x.Error(It.IsAny <Exception>(), "Error processing message {@TestCommand}", It.IsAny <TestCommand>()), Times.Once);
        }