Exemple #1
0
        public async Task Log_Publish()
        {
            // Act
            await _redqueueDecorator.Publish("channel", "message");

            // Assert
            _logger.Received().Log(Arg.Any <LogLevel>(), Arg.Any <string>());
            _redqueue.Received().Publish(Arg.Is("channel"), Arg.Is("message")).Wait();
        }
        public void GivenLogPipelineBehavior_WhenCallHandle_ShouldLogRequestResponse()
        {
            // assign
            var command = new SignUpAccountCommand
            {
                MemberId = 0
            };
            var next = Substitute.For <RequestHandlerDelegate <SimpleResponse <AccountModel> > >();

            next.Invoke().Returns(new SimpleResponse <AccountModel>());

            // act
            _pipeline.Handle(command, CancellationToken.None, next);

            // assert
            _logger.Received(1).MockLog(LogLevel.Information, "Received request for SignUpAccountCommand.", null);
            _logger.Received(1).MockLog(LogLevel.Information, "Returned response for SignUpAccountCommand.", null);
        }
Exemple #3
0
        public async Task Log_Exists()
        {
            // Arrange
            _redcache.Exists(Arg.Any <string>()).Returns(true);

            // Act
            var result = await _redcacheDecorator.Exists("key");

            // Assert
            _logger.Received().Log(Arg.Any <LogLevel>(), Arg.Any <string>());
            _redcache.Received().Exists(Arg.Is("key")).Wait();
            result.Should().BeTrue();
        }
Exemple #4
0
 private void AssertLogging(LogLevel logLevel, string errorMessage, Exception ex)
 {
     _logger.Received(1).MockLog(logLevel, errorMessage, ex);
 }