You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.BeforeEachAsync(async c =>
{
using var scope = Server.Services.CreateScope(); //Breakpoint A
var userManager = scope.ServiceProvider.GetService<UserManager<User>>();
var signInManager = scope.ServiceProvider.GetService<SignInManager<User>>();
var user = new User("TestUser", Guid.NewGuid().ToString());
await userManager.CreateAsync(user); // This actually goes to the database, so it takes a while
c.User = await signInManager.CreateUserPrincipalAsync(user); //Breakpoint B
});
I also have the following code in my StartUp:
app.Use(async (context, next) =>
{
if (!context.User.Identity.IsAuthenticated) //Breakpoint C
{
await context.ChallengeAsync();
return;
}
await next();
});
When I run my tests, I keep getting status 302 with a redirect to my loginpage. When I debug my tests the order in which my breakpoints are hit is A - C - B. This would mean that my BeforeEach code is run in parallel with the actual HttpRequest. Either I'm doing something wrong, or something seems very wrong here.
The text was updated successfully, but these errors were encountered:
I committed a fix on the pull request. Asp.net Core's internal void Configure(Action<HttpContext> configureContext) is not async, so you everything you put in BeforeEachAsync is never awaited :(
I have the following BeforeEachAsync code:
I also have the following code in my
StartUp
:When I run my tests, I keep getting status 302 with a redirect to my loginpage. When I debug my tests the order in which my breakpoints are hit is
A - C - B
. This would mean that myBeforeEach
code is run in parallel with the actual HttpRequest. Either I'm doing something wrong, or something seems very wrong here.The text was updated successfully, but these errors were encountered: