XunitTestLoggerEntry Class
Definition
- Namespace
- Codebelt.Extensions.Xunit.Hosting
- Assemblies
- Codebelt.Extensions.Xunit.Hosting.dll
Represents a captured log-entry for testing purposes. This record encapsulates the LogLevel, EventId and message.
public record XunitTestLoggerEntry : IEquatable<XunitTestLoggerEntry>
- Inheritance
-
XunitTestLoggerEntry
- Implements
Examples
The following example creates an XunitTestLoggerEntry record and formats its message as a string. Each entry captures the LogLevel, EventId, and message text of a single log statement written during a test, and the record's ToString() method returns the message for easy inspection in assertions.
using Codebelt.Extensions.Xunit.Hosting;
using Microsoft.Extensions.Logging;
namespace HostFixtureTests;
public class LogEntryExample
{
public string FormatEntry()
{
var entry = new XunitTestLoggerEntry(LogLevel.Warning, new EventId(1001, "MyEvent"), "Something unexpected happened.");
return entry.ToString();
}
}
Constructors
| Name | Description |
|---|---|
| XunitTestLoggerEntry(LogLevel, EventId, string) | Initializes a new instance of the XunitTestLoggerEntry class. |
Properties
| Name | Description |
|---|---|
| Id | Gets the event identifier. |
| Message | Gets the value of the message. |
| Severity | Gets the log level. |
Methods
| Name | Description |
|---|---|
| ToString() | Returns a string that represents this instance. |