Repository navigation
Replies: 3 comments 4 replies
|
Hi @AFAde Can you tell me what version of bUnit you are using? |
1 reply
|
Hey @DarthPedro Do you have a moment to help troubleshoot this problem? My reproduction confirms this: CUT: @using Microsoft.AspNetCore.Components.Authorization
Is in myTestRole = @isInRole
@code {
private bool isInRole;
[CascadingParameter]
public Task<AuthenticationState> AuthenticationStateTask { get; set; }
protected override async Task OnInitializedAsync()
{
var authenticationState = await AuthenticationStateTask;
isInRole = authenticationState.User.IsInRole("myTestRole");
}
}Test: public class AuthyTest : TestContext
{
[Fact]
public void TestName()
{
var authCtx = this.AddTestAuthorization();
authCtx.SetAuthorized("egil");
authCtx.SetRoles("myTestRole");
var cut = RenderComponent<Authy>();
cut.WaitForAssertion(() => cut.MarkupMatches("Is in myTestRole = true"));
}
}What I notice is that |
2 replies
|
I set my view up to check roles then I tried it with: and it seems like its working for me, I hit the breakpoint and had the role, presume this is fixed? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello,
in the code behind of a component we have the following code
In my test, the code looks like the following
When running the test, the condition authenticationState.User.IsInRole("myTestRole") is never true.
Could you please help me with that?
Thanks
All reactions