Beispiel #1
0
        public void PARSER_SHOULD_ADD_EXCEPTION_STRING_WHEN_EXCEPTION_IS_REQUIRED()
        {
            //Arrange
            var exception        = new Exception();
            var loggingEvent     = new LoggingEvent(GetType(), null, null, Level.Info, null, exception);
            var parser           = new BasicLoggingEventParser(string.Empty, FixFlags.Exception, false, _exceptionFactory);
            var resultDictionary = new Dictionary <string, object>();

            //Act
            parser.ParseException(loggingEvent, resultDictionary);

            //Assert
            resultDictionary["Exception"].Should().BeEquivalentTo(loggingEvent.GetExceptionString());
        }
Beispiel #2
0
        public void PARSER_SHOULD_NOT_ADD_EXCEPTION_WHEN_REQUIRED_AND_EXCEPTION_IS_NULL()
        {
            //Arrange
            var loggingEvent     = new LoggingEvent(GetType(), null, null, Level.Info, null, null);
            var parser           = new BasicLoggingEventParser(string.Empty, FixFlags.None, true, _exceptionFactory);
            var resultDictionary = new Dictionary <string, object>();

            //Act
            parser.ParseException(loggingEvent, resultDictionary);

            //Assert
            resultDictionary.ContainsKey("Exception").Should().BeFalse();
            resultDictionary.ContainsKey("ExceptionObject").Should().BeFalse();
        }
Beispiel #3
0
        public void PARSER_SHOULD_ADD_EXCEPTION_OBJECT_WHEN_EXCEPTION_IS_REQUIRED_AND_SERIALIZE_OBJECTS_IS_ENABLED()
        {
            //Arrange
            var exception     = new Exception();
            var loggingEvent  = new LoggingEvent(GetType(), null, null, Level.Info, null, exception);
            var jsonException = new JsonSerializableException();

            _exceptionFactory.Create(exception).Returns(jsonException);
            var parser           = new BasicLoggingEventParser(string.Empty, FixFlags.Exception, true, _exceptionFactory);
            var resultDictionary = new Dictionary <string, object>();

            //Act
            parser.ParseException(loggingEvent, resultDictionary);

            //Assert
            resultDictionary["ExceptionObject"].Should().Be(jsonException);
        }