ant-design-blazor/tests/AntDesign.TestKit/AntDesignTestBase.cs
Andrzej Bakun d843898cb8 tests: clean-up (#2050)
* tests: clean-up

* tests: missed warnings & exceptions fix

* build: comments fix

* docs: xml comments fixed to stop warnings
2021-10-22 12:45:00 +08:00

35 lines
1.1 KiB
C#

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