using Bunit;
using Marathon.UI.Resources;
using Marathon.UI.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using MudBlazor.Services;
namespace Marathon.UI.Tests.Support;
///
/// Shared bUnit with the Marathon.UI services
/// pre-registered: localizer, theme + locale state, in-memory settings writer,
/// MudBlazor services, and a no-op logger.
///
public abstract class MarathonTestContext : TestContext
{
protected TestSettingsWriter Writer { get; } = new();
protected ThemeState Theme { get; } = new();
protected LocaleState Locale { get; } = new();
protected EventBrowsingState BrowsingState { get; } = new();
protected FakeEventBrowsingService Browsing { get; } = new();
protected MarathonTestContext()
{
Services.AddSingleton(Writer);
Services.AddSingleton(Writer);
Services.AddSingleton(Theme);
Services.AddSingleton(Locale);
Services.AddSingleton(BrowsingState);
Services.AddSingleton(Browsing);
Services.AddSingleton(typeof(IStringLocalizer<>), typeof(TestLocalizer<>));
Services.AddSingleton(typeof(ILogger<>), typeof(NullLogger<>));
Services.AddLogging();
Services.AddMudServices();
// bUnit defaults JS interop to Strict; loosen so MudBlazor's interop
// calls don't blow up tests that aren't asserting on JS-driven UI.
JSInterop.Mode = JSRuntimeMode.Loose;
}
}