-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Testing Blazor components that uses LazyAssemblyLoader
is likely not going to be possible with bUnit without making it possible for the test to provide its own implementation of LazyAssemblyLoader
as a mock.
Right now, the type is a sealed class
, which will make mocking it hard (assuming this is the one that will ship in P8: .../Components/WebAssembly/WebAssembly/src/Services/LazyAssemblyLoader.cs - I did not find any other implementations while searching the repo).
Suggested solution - follow in NavigationManager's footsteps
Consider making LazyAssemblyLoader
an abstract class, and with an abstract LoadAssembliesAsync(...)
method. Then you can provide a sealed internal implementation which is used in production, and users are able to mock it during testing.
This works reasonably well with NavigationManager
. Alternatively, expose the feature as an ILazyAssemblyLoader
. This makes mocking even more intuitive for testers.
cc. @captainsafia
Related: bUnit-dev/bUnit#115