Пример #1
0
        public void ShouldCallValidate_WhenHaveValidator()
        {
            InitializeValidators();
            Dispatcher.Validate(Message);

            MockedValidator.Verify(x => x.Validate(Message));
        }
Пример #2
0
        public async void ShouldApplyValidation_WhenDispatchQuery()
        {
            InitializeValidators();
            MockedValidator.Setup(x => x.Validate(Message)).Throws(new DispatcherException());

            Should
            .Throw <DispatcherException>(() => ((IDispatcher)Dispatcher).Dispatch <Message, Result>(Message));

            await Should
            .ThrowAsync <DispatcherException>(async() => await ((IAsyncDispatcher)Dispatcher).DispatchAsync <Message, Result>(Message));

            await Should
            .ThrowAsync <DispatcherException>(async() => await ((ICancellableAsyncDispatcher)Dispatcher).DispatchAsync <Message, Result>(Message, CancellationToken));
        }