void OptionsNullSetsMessageVersionToNullValue() { MessageEnricherOptions nullOptions = null; var iOptions = new Mock <IOptions <MessageEnricherOptions> >(MockBehavior.Strict); iOptions.SetupGet((x) => x.Value).Returns(nullOptions); var enricher = new MessageEnricher(iOptions.Object); Assert.Equal(MessageDefaults.NullValue, MessageDefaults.NullValue); }
void MessageVersionIsSetFromOptions() { var options = new MessageEnricherOptions() { MessageVersion = "12" }; var iOptions = new Mock <IOptions <MessageEnricherOptions> >(MockBehavior.Strict); iOptions.SetupGet((x) => x.Value).Returns(options); var enricher = new MessageEnricher(iOptions.Object); Assert.Equal(options.MessageVersion, enricher.MessageVersion); }
void MessageVersionIsAddedToLogEvent() { var options = new MessageEnricherOptions() { MessageVersion = "2" }; var iOptions = new Mock <IOptions <MessageEnricherOptions> >(MockBehavior.Strict); iOptions.SetupGet(x => x.Value).Returns(options); var enricher = new MessageEnricher(iOptions.Object); var tokens = new List <MessageTemplateToken>(); var properties = new List <LogEventProperty>(); var logEvent = new LogEvent(DateTime.Now, LogEventLevel.Information, null, new MessageTemplate(tokens), properties); enricher.Enrich(logEvent, null); Assert.Equal(1, logEvent.Properties.Count); Assert.Collection(logEvent.Properties, x => Assert.Equal(MessageDefaults.MessageVersionProperty, x.Key)); }
void MessageVersionIsInitialized() { var options = new MessageEnricherOptions(); Assert.Equal(MessageDefaults.DefaultMessageVersion, options.MessageVersion); }