diff --git a/Source/Csla.Blazor.Test/AppContext/ContextManagerTests.cs b/Source/Csla.Blazor.Test/AppContext/ContextManagerTests.cs new file mode 100644 index 0000000000..e273986d73 --- /dev/null +++ b/Source/Csla.Blazor.Test/AppContext/ContextManagerTests.cs @@ -0,0 +1,67 @@ +//----------------------------------------------------------------------- +// +// Copyright (c) Marimer LLC. All rights reserved. +// Website: https://cslanet.com +// +// Context Manager configuration tests +//----------------------------------------------------------------------- + +using Csla.Configuration; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Csla.Blazor.Test.AppContext; + +/// +/// Context Manager configuration tests +/// +[TestClass] +public class ContextManagerTests +{ + [TestMethod] + public void UseApplicationContextManagerInMemory() + { + var services = new ServiceCollection(); + services.AddScoped(); + services.AddHttpContextAccessor(); + services.AddCsla(o => o + .AddAspNetCore() + .AddServerSideBlazor(o => o.UseInMemoryApplicationContextManager = true)); + var serviceProvider = services.BuildServiceProvider(); + + var activeState = serviceProvider.GetRequiredService(); + activeState.CircuitExists = true; + + var applicationContext = serviceProvider.GetRequiredService(); + Assert.IsInstanceOfType(applicationContext.ContextManager, typeof(Csla.AspNetCore.Blazor.ApplicationContextManagerInMemory)); + } + + [TestMethod] + public void UseApplicationContextManagerBlazor() + { + var services = new ServiceCollection(); + services.AddScoped(); + services.AddHttpContextAccessor(); + services.AddCsla(o => o + .AddAspNetCore() + .AddServerSideBlazor(o => o.UseInMemoryApplicationContextManager = false)); + var serviceProvider = services.BuildServiceProvider(); + + var activeState = serviceProvider.GetRequiredService(); + activeState.CircuitExists = true; + + var applicationContext = serviceProvider.GetRequiredService(); + Assert.IsInstanceOfType(applicationContext.ContextManager, typeof(Csla.AspNetCore.Blazor.ApplicationContextManagerBlazor)); + + } +} + + +public class AuthenticationStateProviderFake : AuthenticationStateProvider +{ + public override Task GetAuthenticationStateAsync() + { + throw new System.NotImplementedException(); + } +}