public void TryGetRawValue_WhenEmpty_ShouldNotFailWithNullException() { // Arrange SimpleLayout l = "${event-properties:eventId:whenEmpty=0}"; var logEventInfo = LogEventInfo.CreateNullEvent(); l.Precalculate(logEventInfo); // Act var success = l.TryGetRawValue(logEventInfo, out var value); // Assert Assert.False(success, "Missing EventId"); }
public void TryGetRawValue_MutableLayoutRender_ShouldGiveNullRawValue() { // Arrange SimpleLayout l = "${event-properties:builder}"; var logEventInfo = LogEventInfo.CreateNullEvent(); logEventInfo.Properties["builder"] = new StringBuilder("mybuilder"); l.Precalculate(logEventInfo); // Act var success = l.TryGetRawValue(logEventInfo, out var value); // Assert Assert.False(success); Assert.Null(value); }
public void TryGetRawValue_ImmutableLayoutRender_ShouldGiveRawValue() { // Arrange SimpleLayout l = "${event-properties:correlationid}"; var logEventInfo = LogEventInfo.CreateNullEvent(); var correlationId = Guid.NewGuid(); logEventInfo.Properties["correlationid"] = correlationId; l.Precalculate(logEventInfo); // Act var success = l.TryGetRawValue(logEventInfo, out var value); // Assert Assert.True(success, "success"); Assert.IsType<Guid>(value); Assert.Equal(correlationId, value); }