-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
using static Sherlog.Formatters.ColorCodeFormatter; | ||
|
||
namespace Sherlog.Formatters.Tests | ||
{ | ||
public class ColorCodeFormatterTests | ||
{ | ||
readonly ColorCodeFormatter _formatter; | ||
readonly Logger _logger; | ||
|
||
public ColorCodeFormatterTests() | ||
{ | ||
_formatter = new ColorCodeFormatter(); | ||
_logger = new Logger("TestLogger"); | ||
} | ||
|
||
[Fact] | ||
public void FormatsStringUsingTraceColors() => _formatter.FormatMessage(_logger, LogLevel.Trace, "test message") | ||
.Should().Be($"{Esc}{CyanBackground}{Esc}{WhiteForeground}test message{Esc}{Reset}"); | ||
|
||
[Fact] | ||
public void FormatsStringUsingDebugColors() => _formatter.FormatMessage(_logger, LogLevel.Debug, "test message") | ||
.Should().Be($"{Esc}{NoBackground}{Esc}{BlueForeground}test message{Esc}{Reset}"); | ||
|
||
[Fact] | ||
public void FormatsStringUsingInfoColors() => _formatter.FormatMessage(_logger, LogLevel.Info, "test message") | ||
.Should().Be($"{Esc}{NoBackground}{Esc}{GreenForeground}test message{Esc}{Reset}"); | ||
|
||
[Fact] | ||
public void FormatsStringUsingWarnColors() => _formatter.FormatMessage(_logger, LogLevel.Warn, "test message") | ||
.Should().Be($"{Esc}{NoBackground}{Esc}{YellowForeground}test message{Esc}{Reset}"); | ||
|
||
[Fact] | ||
public void FormatsStringUsingErrorColors() => _formatter.FormatMessage(_logger, LogLevel.Error, "test message") | ||
.Should().Be($"{Esc}{RedBackground}{Esc}{WhiteForeground}test message{Esc}{Reset}"); | ||
|
||
[Fact] | ||
public void FormatsStringUsingFatalColors() => _formatter.FormatMessage(_logger, LogLevel.Fatal, "test message") | ||
.Should().Be($"{Esc}{MagentaBackground}{Esc}{WhiteForeground}test message{Esc}{Reset}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters