Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve code repetition #1

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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