public void InvocationEnricher_GivenTestInvocation_WhenEnricherApplied_ThenPropertiesAdded() { var invocation = new TestInvocation(); var invocationEnricher = new InvocationEnricher(invocation); var logEvent = new LogEvent(DateTimeOffset.UtcNow, LogEventLevel.Information, null, new MessageTemplate(new List <MessageTemplateToken>()), new List <LogEventProperty>()); invocationEnricher.Enrich(logEvent, null); logEvent.Properties.Count.Should().Be(3); logEvent.Properties[InvocationEnricher.NamespacePropertyName].ToString().Should().Be($@"""{invocation.TargetType.Namespace}"""); logEvent.Properties[InvocationEnricher.TypePropertyName].ToString().Should().Be($@"""{invocation.TargetType.Name}"""); logEvent.Properties[InvocationEnricher.MethodPropertyName].ToString().Should().Be($@"""{invocation.Method.Name}"""); }
public void InvocationEnricher_Enrich_PropertiesAdded() { var invocation = new TestInvocation(); var invocationEnricher = new InvocationEnricher(invocation); var logEvent = new LogEvent(DateTimeOffset.UtcNow, LogEventLevel.Information, null, new MessageTemplate(new List <MessageTemplateToken>()), new List <LogEventProperty>()); invocationEnricher.Enrich(logEvent, null); Assert.AreEqual(3, logEvent.Properties.Count); Assert.AreEqual($"\"{invocation.TargetType.Namespace}\"", logEvent.Properties[InvocationEnricher.NamespacePropertyName].ToString()); Assert.AreEqual($"\"{invocation.TargetType.Name}\"", logEvent.Properties[InvocationEnricher.TypePropertyName].ToString()); Assert.AreEqual($"\"{invocation.Method.Name}\"", logEvent.Properties[InvocationEnricher.MethodPropertyName].ToString()); }