Replies: 3 comments 4 replies
-
Hi @AFAde Can you tell me what version of bUnit you are using? |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
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
Beta Was this translation helpful? Give feedback.
All reactions