Rename and move the tests project to be consistent with the other projects
This commit is contained in:
parent
83cc477170
commit
10283a2053
9 changed files with 3 additions and 3 deletions
25
Start/Tests/Client/Store/ContainerListTests.cs
Normal file
25
Start/Tests/Client/Store/ContainerListTests.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Start.Client.Store.Features.ContainersList;
|
||||
|
||||
namespace Start_Tests.Client.Store {
|
||||
[TestClass]
|
||||
public class ContainerListTests : UnitTestWithFluxor {
|
||||
public TestContext TestContext { get; set; }
|
||||
// Only RootState is needed, so no need to get child objects
|
||||
|
||||
[TestMethod]
|
||||
public void OnFetchContainersList() {
|
||||
base.Dispatcher.Dispatch(new FetchContainerListAction());
|
||||
|
||||
Assert.IsTrue(base.State.Value.ContainerListState.IsLoadingContainersList);
|
||||
Assert.AreEqual(0, this.State.Value.ContainerListState.Containers.Count);
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void InitializeState() {
|
||||
TestContext.WriteLine("Resetting Fluxor state");
|
||||
base.ResetState();
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Start/Tests/Client/Store/UnitTestWithFluxor.cs
Normal file
39
Start/Tests/Client/Store/UnitTestWithFluxor.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
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 IDispatcher Dispatcher { get; set; }
|
||||
protected IState<RootState> 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<IBookmarksApi>(sp => new MockBookmarksApi());
|
||||
BunitTc.Services.AddScoped<IBookmarkGroupsApi>(sp => new MockBookmarkGroupsApi());
|
||||
BunitTc.Services
|
||||
.AddScoped<IBookmarkContainersApi>(sp => new MockBookmarkContainersApi());
|
||||
|
||||
this.Store = this.BunitTc.Services.GetRequiredService<IStore>();
|
||||
this.Dispatcher = this.BunitTc.Services.GetRequiredService<IDispatcher>();
|
||||
this.State = this.BunitTc.Services.GetRequiredService<IState<RootState>>();
|
||||
this.Store.InitializeAsync().Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue