public void CONVERT_FILTER_SHOULD_USE_TO_STRING_ON_CORRECT_KEY() { //Arrange var filter = new ConvertFilter(); const string key = "key"; const string stringValue = "hello"; filter.AddToString(key); var obj = new MockEventObject(stringValue); var eventProperties = new Dictionary <string, object> { { key, obj } }; //Act filter.PrepareEvent(eventProperties); //Assert eventProperties[key].Should().Be(stringValue); }
public void can_parse_log4net_context_stacks() { const string sourceKey = "UserName"; ElasticAppenderFilters oldFilters = null; QueryConfiguration(appender => { oldFilters = appender.ElasticFilters; appender.ElasticFilters = new ElasticAppenderFilters(); var convert = new ConvertFilter(); convert.AddToString(sourceKey); var toArray = new ConvertToArrayFilter { SourceKey = sourceKey }; convert.AddToArray(toArray); appender.ElasticFilters.AddConvert(convert); }); LogicalThreadContext.Stacks[sourceKey].Push("name1"); LogicalThreadContext.Stacks[sourceKey].Push("name2"); _log.Info("hi"); Client.Refresh(TestIndex); var res = Client.Search <JObject>(s => s.AllIndices().Type("LogEvent").Take(1)); var doc = res.Documents.First(); var usrName = doc[sourceKey]; Assert.NotNull(usrName); Assert.AreEqual("name1", usrName[0].Value <string>()); Assert.AreEqual("name2", usrName[1].Value <string>()); QueryConfiguration(appender => { appender.ElasticFilters = oldFilters; }); }