using System; using Blazored.LocalStorage; using Fluxor; using Microsoft.Extensions.DependencyInjection; using Start.Client.Store.State; using Start.Shared.Api; using Start_Tests.Client.MockApis; namespace Start_Tests.Client.Store { public abstract class UnitTestWithFluxor { protected IServiceProvider ServiceProvider { get; set; } protected IStore Store { get; set; } protected IState State { get; set; } // Add child states in the individual tests protected Bunit.TestContext BunitTc { get; set; } public UnitTestWithFluxor() { this.ResetState(); } public void ResetState() { this.BunitTc = new Bunit.TestContext(); BunitTc.Services.AddBlazoredLocalStorage(); BunitTc.Services.AddFluxor(config => config.ScanAssemblies(typeof(RootState).Assembly)); BunitTc.Services.AddScoped(sp => new MockBookmarksApi()); BunitTc.Services.AddScoped(sp => new MockBookmarkGroupsApi()); BunitTc.Services .AddScoped(sp => new MockBookmarkContainersApi()); this.Store = this.BunitTc.Services.GetRequiredService(); this.State = this.BunitTc.Services.GetRequiredService>(); this.Store.InitializeAsync().Wait(); } } }