Skip to content

Commit

Permalink
#4182 Fix Blazor context manager issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rockfordlhotka committed Oct 1, 2024
1 parent 5748baf commit 9607d51
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private void AuthenticationStateProvider_AuthenticationStateChanged(Task<Authent
/// </summary>
public bool IsValid
{
get { return HttpContext is not null || ActiveCircuitState.CircuitExists; }
get { return ActiveCircuitState.CircuitExists; }
}

/// <summary>
Expand Down
20 changes: 19 additions & 1 deletion Source/Csla.Blazor.Test/AppContext/ContextManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,30 @@ public void UseBlazorApplicationContextManager()
var serviceProvider = services.BuildServiceProvider();

var activeState = serviceProvider.GetRequiredService<AspNetCore.Blazor.ActiveCircuitState>();
activeState.CircuitExists = false;
activeState.CircuitExists = true;

var applicationContext = serviceProvider.GetRequiredService<ApplicationContext>();
Assert.IsInstanceOfType(applicationContext.ContextManager, typeof(Csla.AspNetCore.Blazor.ApplicationContextManagerBlazor));
}

[TestMethod]
public void UseAspNetCoreOverBlazorApplicationContextManager()
{
var services = new ServiceCollection();
services.AddScoped<AuthenticationStateProvider, AuthenticationStateProviderFake>();
services.AddScoped<IHttpContextAccessor, HttpContextAccessorFake>();
services.AddCsla(o => o
.AddAspNetCore()
.AddServerSideBlazor(o => o.UseInMemoryApplicationContextManager = false));
var serviceProvider = services.BuildServiceProvider();

var activeState = serviceProvider.GetRequiredService<AspNetCore.Blazor.ActiveCircuitState>();
activeState.CircuitExists = false;

var applicationContext = serviceProvider.GetRequiredService<ApplicationContext>();
Assert.IsInstanceOfType(applicationContext.ContextManager, typeof(Csla.AspNetCore.ApplicationContextManagerHttpContext));
}

[TestMethod]
public void UseAspNetCoreApplicationContextManager()
{
Expand Down

0 comments on commit 9607d51

Please sign in to comment.