Пример #1
0
        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");
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }