Skip to content

Commit

Permalink
Add extra unit test to check with a custom defined length of -1, or m…
Browse files Browse the repository at this point in the history
…aximum field length
  • Loading branch information
andypeeters authored and ckadluba committed Jun 17, 2022
1 parent 01b5da0 commit 083ea93
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ public void GetStandardColumnNameAndValueForMessageReturnsSimpleTextMessageKeyVa
Assert.Equal(messageText, result.Value);
}

[Fact]
public void GetStandardColumnNameAndValueForMessageReturnsSimpleTextMessageKeyValueWithMaxDataLengthDefined()
{
// Arrange
const string messageText = "A long test message";
var logEvent = new LogEvent(
new DateTimeOffset(2020, 1, 1, 0, 0, 0, 0, TimeSpan.Zero),
LogEventLevel.Debug, null, new MessageTemplate(new List<MessageTemplateToken>() { new TextToken(messageText) }),
new List<LogEventProperty>());
var columnOptions = new Serilog.Sinks.MSSqlServer.ColumnOptions { Message = { DataLength = -1 } };
SetupSut(columnOptions);

// Act
var result = _sut.GetStandardColumnNameAndValue(StandardColumn.Message, logEvent);

// Assert
Assert.Equal("Message", result.Key);
Assert.Equal(messageText, result.Value);
}

[Fact]
public void GetStandardColumnNameAndValueForMessageReturnsTrimmedSimpleTextMessageKeyValue()
{
Expand Down

0 comments on commit 083ea93

Please sign in to comment.