mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-25 08:22:08 +00:00
Improve IHttpClient factories (#20)
Codestyle fixes Setup CODEOWNERS Setup dependabot
This commit is contained in:
@@ -2,26 +2,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SystemExtensions.NetStandard.Tests.Logging.Models
|
||||
namespace SystemExtensions.NetStandard.Tests.Logging.Models;
|
||||
|
||||
public sealed class CachingLogger<T> : ILogger<T>
|
||||
{
|
||||
public sealed class CachingLogger<T> : ILogger<T>
|
||||
public List<string> LogCache { get; } = new();
|
||||
|
||||
public IDisposable BeginScope<TState>(TState state)
|
||||
{
|
||||
public List<string> LogCache { get; } = new();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDisposable BeginScope<TState>(TState state)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public bool IsEnabled(LogLevel logLevel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsEnabled(LogLevel logLevel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
{
|
||||
var message = formatter(state, exception);
|
||||
this.LogCache.Add(message);
|
||||
}
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
{
|
||||
var message = formatter(state, exception);
|
||||
this.LogCache.Add(message);
|
||||
}
|
||||
}
|
||||
@@ -4,257 +4,256 @@ using FluentAssertions;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using SystemExtensions.NetStandard.Tests.Logging.Models;
|
||||
|
||||
namespace System.Logging.Tests
|
||||
namespace System.Logging.Tests;
|
||||
|
||||
[TestClass]
|
||||
public class ScopedLoggerTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ScopedLoggerTests
|
||||
private const string Flow = "Flow";
|
||||
private const string Message = "Some message";
|
||||
private readonly CachingLogger<ScopedLoggerTests> cachingLogger = new();
|
||||
|
||||
[TestMethod]
|
||||
public void CreateLogger_CreatesNewLogger()
|
||||
{
|
||||
private const string Flow = "Flow";
|
||||
private const string Message = "Some message";
|
||||
private readonly CachingLogger<ScopedLoggerTests> cachingLogger = new();
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.CreateLogger_CreatesNewLogger), Flow);
|
||||
scopedLogger.Should().BeOfType<ScopedLogger<ScopedLoggerTests>>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CreateLogger_CreatesNewLogger()
|
||||
[TestMethod]
|
||||
public void CreateLogger_NullScope_ThrowsArgumentNullException()
|
||||
{
|
||||
var action = new Action(() =>
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.CreateLogger_CreatesNewLogger), Flow);
|
||||
scopedLogger.Should().BeOfType<ScopedLogger<ScopedLoggerTests>>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CreateLogger_NullScope_ThrowsArgumentNullException()
|
||||
{
|
||||
var action = new Action(() =>
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(null, Flow);
|
||||
});
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(null, Flow);
|
||||
});
|
||||
|
||||
|
||||
action.Should().Throw<ArgumentNullException>();
|
||||
}
|
||||
action.Should().Throw<ArgumentNullException>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CreateLogger_NullFlow_ReturnsScopedLogger()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.CreateLogger_NullFlow_ReturnsScopedLogger), null);
|
||||
}
|
||||
[TestMethod]
|
||||
public void CreateLogger_NullFlow_ReturnsScopedLogger()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.CreateLogger_NullFlow_ReturnsScopedLogger), null);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogInformation_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogInformation_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogInformation_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogInformation_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogInformation_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogInformation_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogInformation(Message);
|
||||
scopedLogger.LogInformation(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogInformation_EmptyFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogInformation_LogsExpected), string.Empty);
|
||||
var expectedMessage = $"{nameof(this.LogInformation_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogInformation_EmptyFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogInformation_LogsExpected), string.Empty);
|
||||
var expectedMessage = $"{nameof(this.LogInformation_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogInformation(Message);
|
||||
scopedLogger.LogInformation(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogInformation_WhitespaceFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogInformation_LogsExpected), " ");
|
||||
var expectedMessage = $"{nameof(this.LogInformation_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogInformation_WhitespaceFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogInformation_LogsExpected), " ");
|
||||
var expectedMessage = $"{nameof(this.LogInformation_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogInformation(Message);
|
||||
scopedLogger.LogInformation(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogDebug_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogDebug_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogDebug_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogDebug_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogDebug_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogDebug_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogDebug(Message);
|
||||
scopedLogger.LogDebug(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogDebug_EmptyFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogDebug_EmptyFlow_LogsExpected), string.Empty);
|
||||
var expectedMessage = $"{nameof(this.LogDebug_EmptyFlow_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogDebug_EmptyFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogDebug_EmptyFlow_LogsExpected), string.Empty);
|
||||
var expectedMessage = $"{nameof(this.LogDebug_EmptyFlow_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogDebug(Message);
|
||||
scopedLogger.LogDebug(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogDebug_WhitespaceFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogDebug_WhitespaceFlow_LogsExpected), " ");
|
||||
var expectedMessage = $"{nameof(this.LogDebug_WhitespaceFlow_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogDebug_WhitespaceFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogDebug_WhitespaceFlow_LogsExpected), " ");
|
||||
var expectedMessage = $"{nameof(this.LogDebug_WhitespaceFlow_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogDebug(Message);
|
||||
scopedLogger.LogDebug(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogWarning_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogWarning_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogWarning_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogWarning_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogWarning_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogWarning_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogWarning(Message);
|
||||
scopedLogger.LogWarning(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogWarning_EmptyFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogWarning_EmptyFlow_LogsExpected), string.Empty);
|
||||
var expectedMessage = $"{nameof(this.LogWarning_EmptyFlow_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogWarning_EmptyFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogWarning_EmptyFlow_LogsExpected), string.Empty);
|
||||
var expectedMessage = $"{nameof(this.LogWarning_EmptyFlow_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogWarning(Message);
|
||||
scopedLogger.LogWarning(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogWarning_WhitespaceFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogWarning_WhitespaceFlow_LogsExpected), " ");
|
||||
var expectedMessage = $"{nameof(this.LogWarning_WhitespaceFlow_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogWarning_WhitespaceFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogWarning_WhitespaceFlow_LogsExpected), " ");
|
||||
var expectedMessage = $"{nameof(this.LogWarning_WhitespaceFlow_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogWarning(Message);
|
||||
scopedLogger.LogWarning(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogError_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogError_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogError_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogError_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogError_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogError_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogError(Message);
|
||||
scopedLogger.LogError(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogError_EmptyFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogError_EmptyFlow_LogsExpected), string.Empty);
|
||||
var expectedMessage = $"{nameof(this.LogError_EmptyFlow_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogError_EmptyFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogError_EmptyFlow_LogsExpected), string.Empty);
|
||||
var expectedMessage = $"{nameof(this.LogError_EmptyFlow_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogError(Message);
|
||||
scopedLogger.LogError(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogError_WhitespaceFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogError_WhitespaceFlow_LogsExpected), " ");
|
||||
var expectedMessage = $"{nameof(this.LogError_WhitespaceFlow_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogError_WhitespaceFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogError_WhitespaceFlow_LogsExpected), " ");
|
||||
var expectedMessage = $"{nameof(this.LogError_WhitespaceFlow_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogError(Message);
|
||||
scopedLogger.LogError(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogCritical_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogCritical_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogCritical_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogCritical_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogCritical_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogCritical_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogCritical(Message);
|
||||
scopedLogger.LogCritical(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogCritical_EmptyFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogCritical_EmptyFlow_LogsExpected), string.Empty);
|
||||
var expectedMessage = $"{nameof(this.LogCritical_EmptyFlow_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogCritical_EmptyFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogCritical_EmptyFlow_LogsExpected), string.Empty);
|
||||
var expectedMessage = $"{nameof(this.LogCritical_EmptyFlow_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogCritical(Message);
|
||||
scopedLogger.LogCritical(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogCritical_WhitespaceFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogCritical_WhitespaceFlow_LogsExpected), " ");
|
||||
var expectedMessage = $"{nameof(this.LogCritical_WhitespaceFlow_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogCritical_WhitespaceFlow_LogsExpected()
|
||||
{
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogCritical_WhitespaceFlow_LogsExpected), " ");
|
||||
var expectedMessage = $"{nameof(this.LogCritical_WhitespaceFlow_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogCritical(Message);
|
||||
scopedLogger.LogCritical(Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogWarning_WithException_LogsExpected()
|
||||
{
|
||||
var exception = new Exception();
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogWarning_WithException_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogWarning_WithException_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogWarning_WithException_LogsExpected()
|
||||
{
|
||||
var exception = new Exception();
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogWarning_WithException_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogWarning_WithException_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogWarning(exception, Message);
|
||||
scopedLogger.LogWarning(exception, Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogError_WithException_LogsExpected()
|
||||
{
|
||||
var exception = new Exception();
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogError_WithException_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogError_WithException_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogError_WithException_LogsExpected()
|
||||
{
|
||||
var exception = new Exception();
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogError_WithException_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogError_WithException_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogError(exception, Message);
|
||||
scopedLogger.LogError(exception, Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LogCritical_WithException_LogsExpected()
|
||||
{
|
||||
var exception = new Exception();
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogCritical_WithException_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogCritical_WithException_LogsExpected)}: {Message}";
|
||||
[TestMethod]
|
||||
public void LogCritical_WithException_LogsExpected()
|
||||
{
|
||||
var exception = new Exception();
|
||||
var scopedLogger = this.cachingLogger.CreateScopedLogger(nameof(this.LogCritical_WithException_LogsExpected), Flow);
|
||||
var expectedMessage = $"[{Flow}] {nameof(this.LogCritical_WithException_LogsExpected)}: {Message}";
|
||||
|
||||
scopedLogger.LogCritical(exception, Message);
|
||||
scopedLogger.LogCritical(exception, Message);
|
||||
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
this.cachingLogger.LogCache.Should().HaveCount(1);
|
||||
this.cachingLogger.LogCache.First().Should().Be(expectedMessage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user