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()); }
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(); }
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); }