Exemplo n.º 1
0
        public async void when_executing_async_command_then_invokes_async_handler()
        {
            var handler = new Mock <IAsyncCommandHandler <AsyncCommand> >();
            var command = new AsyncCommand();

            handler.Setup(x => x.ExecuteAsync(command, CancellationToken.None)).Returns(Task.FromResult(true));
            var bus = new CommandBusComponent(Mock.Of <IComponentModel>(x =>
                                                                        x.GetExtensions <IAsyncCommandHandler <AsyncCommand> >() == new[] { handler.Object }));

            await bus.ExecuteAsync(command, CancellationToken.None);

            handler.Verify(x => x.ExecuteAsync(command, CancellationToken.None));
        }
Exemplo n.º 2
0
        public async void when_executing_async_command_with_result_without_handler_then_throws()
        {
            var bus = new CommandBusComponent(Mock.Of <IComponentModel>());

            await Assert.ThrowsAsync <NotSupportedException> (() => bus.ExecuteAsync <Result> (new AsyncCommandWithResult(), CancellationToken.None));
        }