public async Task ItShouldThrowIfNoHandlerCanBeFound()
        {
            var serviceProvider = new ServiceCollection().BuildServiceProvider();
            var command         = new TestCommand();
            var processor       = new ServiceProviderBackgroundProcessor(serviceProvider);

            Func <Task> act = async() => await processor.ProcessAsync(command);

            act.Should().Throw <BackgroundProcessingException>().WithMessage("*handler*TestCommand*");
        }
        public async Task ItShouldRelayExceptions()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <IBackgroundCommandHandler <TestErrorCommand>, TestErrorCommandHandler>()
                                  .BuildServiceProvider();
            var command   = new TestErrorCommand();
            var processor = new ServiceProviderBackgroundProcessor(serviceProvider);

            Func <Task> act = async() => await processor.ProcessAsync(command);

            act.Should().Throw <Exception>().WithMessage(command.Id);
        }
        public async Task ItShouldInvokeHandlerWhenFound()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <IBackgroundCommandHandler <TestCommand>, TestCommandHandler>()
                                  .BuildServiceProvider();
            var command   = new TestCommand();
            var processor = new ServiceProviderBackgroundProcessor(serviceProvider);

            await processor.ProcessAsync(command);

            var handler = serviceProvider.GetRequiredService <IBackgroundCommandHandler <TestCommand> >() as TestCommandHandler;

            handler.ReceivedCommand.Should().BeSameAs(command);
        }