public void FormatProcessIdTest() { string categoryName = "test"; LogLevel logLevel = LogLevel.Warning; EventId eventId = new EventId(5, "five"); Exception?ex = null; string message = "fnord"; object[]? scopes = null; string template = "{ProcessId}"; var logTemplate = new LogTemplate(template); var actual = logTemplate.Bind(categoryName, logLevel, eventId, message, ex, scopes); string expected = Process.GetCurrentProcess().Id.ToString(); Assert.AreEqual(expected, actual); }
public void FormatMessagePrefixControlCharacter() { string categoryName = "test"; LogLevel logLevel = LogLevel.Warning; EventId eventId = new EventId(5, "five"); Exception?ex = null; string message = "Something to\tsay"; object[]? scopes = null; string template = "<{MessagePrefix}>"; var logTemplate = new LogTemplate(template); var actual = logTemplate.Bind(categoryName, logLevel, eventId, message, ex, scopes); string expected = "<Something tosay>"; Assert.AreEqual(expected, actual); }
public void FormatIdAndMessageTest() { string categoryName = "test"; LogLevel logLevel = LogLevel.Warning; EventId eventId = new EventId(5, "five"); Exception?ex = null; string message = "fnord"; object[]? scopes = null; string template = "{Id}.{Message}"; var logTemplate = new LogTemplate(template); var actual = logTemplate.Bind(categoryName, logLevel, eventId, message, ex, scopes); string expected = "5.fnord"; Assert.AreEqual(expected, actual); }
public void FormatMessagePrefixLength() { string categoryName = "test"; LogLevel logLevel = LogLevel.Warning; EventId eventId = new EventId(5, "five"); Exception?ex = null; // 1234567890123456789012345678901234567890 string message = "Something to say Something to say Something to say. the rest of the trace."; object[]? scopes = null; string template = "<{MessagePrefix}>"; var logTemplate = new LogTemplate(template); var actual = logTemplate.Bind(categoryName, logLevel, eventId, message, ex, scopes); string expect = "<Something to say Something to say Som...>"; Assert.AreEqual(expect, actual); }
public void FormatPrincipalNameTest() { string categoryName = "test"; LogLevel logLevel = LogLevel.Warning; EventId eventId = new EventId(5, "five"); Exception?ex = null; string message = "fnord"; object[]? scopes = null; string template = "{Id}.{PrincipalName}"; var logTemplate = new LogTemplate(template); string actual; using (var scope = new UserResetScope("testuser")) { actual = logTemplate.Bind(categoryName, logLevel, eventId, message, ex, scopes); } string expected = "5.testuser"; Assert.AreEqual(expected, actual); }