コード例 #1
0
        public void ShouldThrowExcpetion_WhenNoQueryHandler()
        {
            MockedLocator.Setup(method => method.GetAllServices<IQueryHandler<Query, ReadModel>>()).Returns(() => new IQueryHandler<Query, ReadModel>[] { });

            var dispatcher = (IQueryDispatcher)new QueryDispatcher(MockedLocator.Object);
            var action = new Action(() => dispatcher.Dispatch<Query, ReadModel>(new Query()));
            action.ShouldThrowExactly<NoHandlerException>().WithMessage(NoHandlerExceptionMessageExpected);
        }
コード例 #2
0
        public void ShouldThrowExcpetion_WhenMultipleCommandHandler()
        {
            MockedLocator.Setup(method => method.GetAllServices<ICommandHandler<Command, Result>>()).Returns(() => new [] { MockedCommandHandler.Object, MockedCommandHandler.Object });

            var dispatcher = (ICommandDispatcher)new CommandDispatcher(MockedLocator.Object);
            var action = new Action(() => dispatcher.Dispatch<Command, Result>(new Command()));
            action.ShouldThrowExactly<MultipleHandlerException>().WithMessage(MultipleHandlerExceptionMessageExpected);
        }
コード例 #3
0
        public void ShouldThrowExcpetion_WhenNoCommandHandlerWithoutReturn()
        {
            MockedLocator.Setup(method => method.GetAllServices<ICommandHandler<Command>>()).Returns(() => new ICommandHandler<Command>[] { });

            var dispatcher = (ICommandDispatcher)new CommandDispatcher(MockedLocator.Object);
            var action = new Action(() => dispatcher.Dispatch(new Command()));
            action.ShouldThrowExactly<NoHandlerException>().WithMessage(NoHandlerExceptionMessageExpected);
        }