ant-design-blazor/tests/AntDesignTestBase.cs
Patrick f20d863bc3 test: Add ability to use OverlayTrigger in tests (#1227)
* Add TestDomEventService to TestBase

* chore(tests): update to net5

* feat(testdomeventservice): override eventdomservice to null

* fix(AddEventListener): make AddEventListener virtual

* feat(test): add basic overlay test

* fix(name): make name .cs
2021-03-09 13:54:30 +00:00

35 lines
1.0 KiB
C#

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