コード例 #1
0
        public void PARSER_SHOULD_NOT_ADD_ANY_LOCATION_INFO_WHEN_IS_NULL()
        {
            //Arrange
            var loggingEvent = new LoggingEvent(new LoggingEventData {
                LocationInfo = null
            });
            var parser           = new BasicLoggingEventParser(string.Empty, FixFlags.None, true, _exceptionFactory);
            var resultDictionary = new Dictionary <string, object>();

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

            //Assert
            resultDictionary.ContainsKey("LocationInformation").Should().BeFalse();
        }
コード例 #2
0
        public void PARSER_SHOULD_ADD_METHOD_NAME_WHEN_LOCATION_INFO_IS_REQUIRED()
        {
            //Arrange
            var locationInfo = new LocationInfo("class", "method", "file", "line");
            var loggingEvent = new LoggingEvent(new LoggingEventData {
                LocationInfo = locationInfo
            });
            var parser           = new BasicLoggingEventParser(string.Empty, FixFlags.LocationInfo, true, _exceptionFactory);
            var resultDictionary = new Dictionary <string, object>();

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

            //Assert
            var resultLocationInfo = resultDictionary["LocationInformation"] as Dictionary <string, object>;

            if (resultLocationInfo != null)
            {
                resultLocationInfo["MethodName"].Should().BeEquivalentTo(locationInfo.MethodName);
            }
        }