-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for custom Service Provider #79
Comments
It's not currently possible. The It sounds like you're proposing a fallback service resolution strategy. I don't think that will work well in all scenarios, and could lead to subtle issues. Take the following example (and assume the service components are singletons): You'd have to ensure that any service in your Autofac container does not depend on a service that is being mocked by the What shortcomings are you finding with the |
Hello @seniorquico ,
Fair enough.
It's not about Autofac is somehow better than TestServiceProvider. My concern is about not making the same work twice and not duplicating a registration logic. Taking into account your fair remark, if I was able to completely replace the TestServiceProvider with Autofac implementation of IServiceProvider (without any fallback resolution strategy), previously substituting required services with mocks in Autofac container, it could solve the problem. |
I don't see any hard dependency on the |
Great. Let me create a pull request soon. |
Hi!
First of all, thank you for the great framework!
I'm trying to find out if there is any possibility to use a custom ServiceProvider. As far as I see, there is none. However, since my projects are based on Autofac modules, I'd like to have such functionality to avoid registering components twice.
The idea is to have a custom ServiceProvider which will first look for mock in Dictionary as it's implemented now and if no suitable implementation found, will look in Autofac container for a ordinary implementation. In this way, I'd need to manually register only services which I need to mock in a particular test.
Thanks.
The text was updated successfully, but these errors were encountered: