moq / Moq.AutoMocker

An auto-mocking IoC container for Moq
MIT License
389 stars 53 forks source link

InjectAttribute #236

Closed kuhnboy closed 1 year ago

kuhnboy commented 1 year ago

How do I have Moq work with Blazor's Razor @inject attribute or [Inject] so that the proper dependencies are injected upon Create<>?

Keboo commented 1 year ago

I think this more hinges on your testing framework and less on AutoMocker.

For example if you are using something like bUnit, it supports adding in an IServiceProvider (as seen here: https://bunit.dev/docs/providing-input/inject-services-into-components.html). AutoMocker also implements the IServiceProvider interface so you could it is in place of where those samples show FallbackServiceProvider

Keboo commented 1 year ago

Closing for now. If you have any follow up feel free to re-open