ant-design-blazor/tests/AntDesign.TestKit/AntDesignTestBase.cs
Andrzej Bakun 713eb6fd94 chore: test cs project to include test runner adapter (#1939)
test: add general overlay disposal method mock
2021-09-13 10:37:16 +08:00

31 lines
957 B
C#

using System;
using System.Globalization;
using Bunit;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.DependencyInjection;
namespace AntDesign.Tests
{
public class AntDesignTestBase : TestContext, IDisposable
{
public TestContext Context => this;
public NavigationManager NavigationManager => Services.GetRequiredService<NavigationManager>();
public AntDesignTestBase()
{
Services.AddAntDesign();
//Needed for Tests using Overlay
Services.AddScoped<AntDesign.JsInterop.DomEventService>(sp => new TestDomEventService(Context.JSInterop.JSRuntime));
JSInterop.SetupVoid(JSInteropConstants.OverlayComponentHelper.DeleteOverlayFromContainer, _ => true);
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US");
}
public void Dispose()
{
Context?.Dispose();
}
}
}