Files
WotBlitzStatisticsBlazor/WotBlitzStatisticsPro.Blazor.Tests/TestContextBase.cs
T

43 lines
1.4 KiB
C#
Raw Normal View History

2021-05-07 16:54:21 +02:00
using Bunit;
using MediatR;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using NUnit.Framework;
using Radzen;
using WotBlitzStatisticsPro.Blazor.Services;
namespace WotBlitzStatisticsPro.Blazor.Tests
{
public class TestContextBase: TestContextWrapper
{
protected Mock<IMediator> MediatorMock;
protected Mock<ISearchDialogService> SearchServiceMock;
protected Mock<INotificationsService> NotificationsServiceMock;
2021-05-07 16:54:21 +02:00
protected MockNavigationManager NavigationManagerMock;
[SetUp]
protected void Init()
{
MediatorMock = new();
SearchServiceMock = new();
NavigationManagerMock = new();
NotificationsServiceMock = new ();
2021-05-07 16:54:21 +02:00
TestContext = new Bunit.TestContext();
TestContext.Services.AddSingleton(MediatorMock.Object);
TestContext.Services.AddLocalization();
TestContext.Services.AddSingleton<DialogService>();
TestContext.Services.AddSingleton<NotificationService>();
2021-05-07 16:54:21 +02:00
TestContext.Services.AddSingleton(SearchServiceMock.Object);
TestContext.Services.AddSingleton(NotificationsServiceMock.Object);
2021-05-07 16:54:21 +02:00
TestContext.Services.AddSingleton<NavigationManager>(NavigationManagerMock);
}
[TearDown]
public void TearDown() => TestContext?.Dispose();
}
}