Open SeanC2222 opened 3 months ago
Thanks for reporting this. My initial take is that we won't be taking a dependency on an 3rd party package to implement a base type or interface from that.
However, I am open to adding to our fake Auth API in (non-breeding way) to enable your scenario in a way that feels natural.
Do you have any suggestions in this regard?
Describe the bug
In the MSAL backed Blazor WASM authentication packages, there exists an overloaded class the
RemoteAuthenticationService
.This service implements the
AuthenticationStateProvider
and anIRemoteAuthenticationService<>
.The DI for this package abuses this a bit by casting the configured
AuthenticationStateProvider
to it's alternate interface form.This doesn't play nicely with BUnit's configuration which simply adds a singleton definition for
AuthenticationStateProvider
for the Fake that doesn't implement both the interface and abstract class.Example: Testing this component:
Any component where the host program uses MSAL:
With this test: Requires Package Reference:
Results in this output:
Expected behavior:
Not triggering the cast error.
Version info:
Additional context:
We're wrapping the BUnit
FakeAuthenticationStateProvider
in an extra layer that implements both theAuthenticationStateProvider
and theIRemoteAuthenticationService
which is working, but it also requires us taking the BUnit implementation out of the DI and sticking ours in based on this little insight. Not ideal.Not sure what the right answer is for BUnit as BUnit targets all Blazor, and this is a WASM specific problem.