-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from skwasjer/feature/remove_netcore31_from_s…
…erver feat: remove .NET Core 3.1 from skwas.MockHttp.Server (EOL)
- Loading branch information
Showing
11 changed files
with
121 additions
and
321 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
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
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
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
230 changes: 0 additions & 230 deletions
230
test/MockHttp.Server.Tests/Fixtures/CapturingLoggerFactoryFixture.cs
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
test/MockHttp.Server.Tests/Fixtures/FakeLogRecordSerialization.cs
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,53 @@ | ||
using System.Text; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Logging.Testing; | ||
|
||
namespace MockHttp.Fixtures; | ||
|
||
internal static class FakeLogRecordSerialization | ||
{ | ||
internal static string Serialize(FakeLogRecord e) | ||
{ | ||
var sb = new StringBuilder(); | ||
const int len = 4; | ||
string indent = new(' ', len + 2); | ||
|
||
sb.AppendLine($"{GetLogLevelString(e.Level)}: {e.Category}[{e.Id.Id}]"); | ||
foreach (IEnumerable<KeyValuePair<string, object?>> scope in e.Scopes.OfType<IEnumerable<KeyValuePair<string, object?>>>()) | ||
{ | ||
sb.Append(indent); | ||
// ReSharper disable once UsageOfDefaultStructEquality | ||
foreach (KeyValuePair<string, object?> kvp in scope) | ||
{ | ||
sb.Append($"=> {kvp} "); | ||
} | ||
|
||
sb.AppendLine(); | ||
} | ||
|
||
sb.Append(indent); | ||
sb.AppendLine(e.Message); | ||
|
||
if (e.Exception is not null) | ||
{ | ||
sb.Append(indent); | ||
sb.AppendLine(e.Exception.ToString()); | ||
} | ||
|
||
return sb.ToString(); | ||
} | ||
|
||
private static string GetLogLevelString(LogLevel logLevel) | ||
{ | ||
return logLevel switch | ||
{ | ||
LogLevel.Trace => "trce", | ||
LogLevel.Debug => "dbug", | ||
LogLevel.Information => "info", | ||
LogLevel.Warning => "warn", | ||
LogLevel.Error => "fail", | ||
LogLevel.Critical => "crit", | ||
_ => throw new ArgumentOutOfRangeException(nameof(logLevel)) | ||
}; | ||
} | ||
} |
Oops, something went wrong.