Skip to content

Commit

Permalink
Merge pull request #1 from chickensoft-games/dry-logs
Browse files Browse the repository at this point in the history
Improve code repetition
  • Loading branch information
wlsnmrk authored Jan 29, 2025
2 parents 7e2fc2f + 59a3023 commit c6c74b6
Show file tree
Hide file tree
Showing 23 changed files with 682 additions and 1,521 deletions.
2 changes: 1 addition & 1 deletion Chickensoft.Log.Tests/badges/branch_coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Chickensoft.Log.Tests/badges/line_coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
285 changes: 0 additions & 285 deletions Chickensoft.Log.Tests/test/src/ConsoleLogTest.cs

This file was deleted.

33 changes: 33 additions & 0 deletions Chickensoft.Log.Tests/test/src/LogFormatterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,39 @@ public void FormatsMessage() {
.ShouldBe($"Info ({_testName}): {_testMsg}");
}

[Fact]
public void FormatsStackTrace() {
var st = new FakeStackTrace("File.cs", "ClassName", "MethodName");
var formatter = new LogFormatter();
formatter.FormatMessage(_testName, st)
.ShouldBe($"Info ({_testName}): ClassName.MethodName in File.cs(1,2)");
}

[Fact]
public void FormatsStackTraceWithoutFile() {
var st = new FakeStackTrace(null, "ClassName", "MethodName");
var formatter = new LogFormatter();
formatter.FormatMessage(_testName, st)
.ShouldBe($"Info ({_testName}): ClassName.MethodName in **(1,2)");
}

[Fact]
public void FormatsStackTraceWithoutClass() {
var st = new FakeStackTrace("File.cs", null, "MethodName");
var formatter = new LogFormatter();
formatter.FormatMessage(_testName, st)
.ShouldBe($"Info ({_testName}): UnknownClass.MethodName in File.cs(1,2)");
}

[Fact]
public void FormatsStackTraceWithoutMethod() {
var st = new FakeStackTrace("File.cs", "ClassName", null);
var formatter = new LogFormatter();
// unknown method is also unknown class
formatter.FormatMessage(_testName, st)
.ShouldBe($"Info ({_testName}): UnknownClass.UnknownMethod in File.cs(1,2)");
}

[Fact]
public void FormatsWarning() {
var formatter = new LogFormatter();
Expand Down
Loading

0 comments on commit c6c74b6

Please sign in to comment.