File: src\ProjectTemplates\Shared\TestOutputLogger.cs
Web Access
Project: src\src\ProjectTemplates\test\Templates.Blazor.WebAssembly.Tests\Templates.Blazor.WebAssembly.Tests.csproj (Templates.Blazor.WebAssembly.Tests)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.Globalization;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;
 
namespace Templates.Test.Helpers;
 
internal sealed class TestOutputLogger : ITestOutputHelper
{
    private readonly ILogger _logger;
 
    public TestOutputLogger(ILogger logger)
    {
        _logger = logger;
    }
 
    public void WriteLine(string message)
    {
        _logger.LogInformation(message);
    }
 
    public void WriteLine(string format, params object[] args)
    {
        if (_logger.IsEnabled(LogLevel.Information))
        {
            _logger.LogInformation(string.Format(CultureInfo.InvariantCulture, format, args));
        }
    }
}