How to pass the AuthenticationState Task cascading parameter to a component under test #192
-
I'm trying to follow on the examples we see in #146 to setup my component to test that receives the Task cascading parameter. I haven't seen any detail on how to pass this to the component. so I tried retrieving the state provider like this And by adding the parameter in the builder like this: But when I check the task inside the component when debugging my test, it is null. Do you have the required steps to achieve this? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
Hi @ThaRaven403 Check out the docs at https://bunit.egilhansen.com/docs/test-doubles/faking-auth.html, they should have all your need. |
Beta Was this translation helpful? Give feedback.
-
Hi @egil ! Sorry for the late reply, but I'm using a different scenario to access the authentication state. I am using a cascading parameter as a parameter in the cs file, as can be seen in this example: https://docs.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-3.1#expose-the-authentication-state-as-a-cascading-parameter I'm querying the result of the task, and this is what I'd like to be able to mock/inject into the component under test |
Beta Was this translation helpful? Give feedback.
-
Great, thanks for the quick reply! If there's anything you'd like me to try out, feel free to ask it'll be a pleasure! |
Beta Was this translation helpful? Give feedback.
-
It looks as if the following works, as it is an unnamed cascading parameter. The other variant should also work, so I am fixing that
|
Beta Was this translation helpful? Give feedback.
It looks as if the following works, as it is an unnamed cascading parameter. The other variant should also work, so I am fixing that