| File: TestServices\CapturingLogger.cs | Web Access |
| Project: src\tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj (Aspire.Cli.Tests) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Logging; namespace Aspire.Cli.Tests.TestServices; /// <summary> /// In-memory logger that records every log call so tests can assert /// on the structured rejection messages emitted by InstallationDiscovery. /// </summary> internal sealed class CapturingLogger<T> : ILogger<T> { public List<(LogLevel Level, string Message)> Entries { get; } = new(); public IDisposable BeginScope<TState>(TState state) where TState : notnull => NullScope.Instance; public bool IsEnabled(LogLevel logLevel) => true; public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter) { Entries.Add((logLevel, formatter(state, exception))); } private sealed class NullScope : IDisposable { public static readonly NullScope Instance = new(); public void Dispose() { } } }