public async Task ReturnsResultOfCommandHandler()
        {
            var commandResult  = CommandResult.Success();
            var command        = new TestCommand();
            var commandHandler = new Mock <ICommandHandler <TestCommand> >();

            commandHandler.Setup(ch => ch.Handle(command))
            .ReturnsAsync(() => commandResult);
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <ICommandHandler <TestCommand> >(commandHandler.Object);
            var commandBus = new CommandBus(serviceCollection.BuildServiceProvider());
            var result     = await commandBus.SubmitAsync(command);

            Assert.Equal(commandResult, result);
        }
 public async Task ThrowsIfCallsCommandWithNoRegisteredCommandHandler()
 {
     var serviceCollection = new ServiceCollection();
     var commandBus        = new CommandBus(serviceCollection.BuildServiceProvider());
     await Assert.ThrowsAsync <ArgumentException>(() => commandBus.SubmitAsync(new TestCommand()));
 }