Beispiel #1
0
        public static void SubscribeToCommand <TCommand>(this INybusConfigurator configurator, CommandReceivedAsync <TCommand> commandReceived)
            where TCommand : class, ICommand
        {
            var handler = new DelegateWrapperCommandHandler <TCommand>(commandReceived);

            SubscribeToCommand <TCommand, DelegateWrapperCommandHandler <TCommand> >(configurator, handler);
        }
Beispiel #2
0
        public void Handler_errors_are_not_caught(IDispatcher dispatcher, ICommandContext <FirstTestCommand> context, Exception error, CommandReceivedAsync <FirstTestCommand> handler)
        {
            Mock.Get(handler).Setup(p => p(It.IsAny <IDispatcher>(), It.IsAny <ICommandContext <FirstTestCommand> >())).Throws(error);

            var sut = new DelegateWrapperCommandHandler <FirstTestCommand>(handler);

            Assert.ThrowsAsync(error.GetType(), () => sut.HandleAsync(dispatcher, context));
        }
Beispiel #3
0
        public async Task Handler_is_executed(IDispatcher dispatcher, ICommandContext <FirstTestCommand> context, CommandReceivedAsync <FirstTestCommand> handler)
        {
            var sut = new DelegateWrapperCommandHandler <FirstTestCommand>(handler);

            await sut.HandleAsync(dispatcher, context);

            Mock.Get(handler).Verify(p => p(dispatcher, context), Times.Once);
        }