Beispiel #1
0
        public async Task MustLogTraceWhenCommandBehaviorPipelineIsExecuted()
        {
            await _sut.Dispatch <IMessage>(null, null);

            _logger.VerifyWasCalled(LogLevel.Trace, _commandBehaviorExecuteLogMessage, Times.Once());
            _logger.VerifyWasCalled(LogLevel.Trace, _handlerInvokedLogMessage, Times.Never());
        }
Beispiel #2
0
        public async Task MustLogTraceForAllHandlersInvoked()
        {
            var listOfRegisteredHandlers = new[] { _handler.Object, _handler.Object, _handler.Object }.TakeWhile(_ => true);

            _serviceProvider.Setup(p => p.GetService(typeof(IEnumerable <IMessageHandler <IMessage> >))).Returns(listOfRegisteredHandlers);
            await _sut.Dispatch <IMessage>(null, null);

            _logger.VerifyWasCalled(LogLevel.Trace,
                                    _eventHandlerInvokedLogMessage,
                                    Times.Exactly(3));
        }
Beispiel #3
0
        public async Task MustLogErrorIfExceptionIsCaught()
        {
            _serviceProvider.Setup(p => p.GetService(typeof(IQueryHandler <TestQuery, string>))).Throws <Exception>();
            await FluentActions.Invoking(async() => await _sut.Query(_query)).Should().ThrowAsync <Exception>();

            _logger.VerifyWasCalled(LogLevel.Error, times: Times.Once());
        }