Use different configurations with Simple Injection

Posted by Ruben.Canton on Stack Overflow See other posts from Stack Overflow or by Ruben.Canton
Published on 2012-12-07T17:01:43Z Indexed on 2012/12/07 17:03 UTC
Read the original article Hit count: 272

Filed under:
|

I'm using the library "Simple Injector" (http://simpleinjector.codeplex.com) and it looks cool and nice. But after building a configuration and use it, now I want to know how to change from one configuration to another.

Scenario: Let's imagine I've set up a configuration in the Global Asax and I have the public and global Container there. Now I want to make some tests and I want them to use mock classes so I want to change the configuration.

I can, of course, build another configuration and assign it to the global Container created by default, so that every time I run a test the alternative configuration will be set. But on doing that and though I'm in development context the Container is changed for everyone, even for normal requests. I know I'm testing in this context and that shouldn't matter, but I have the feeling that this is not the way for doing this... and I wonder how to change from one configuration to another in the correct way.

Note: At Simple Injector documentation says that you can ask questions in stackoverflow so that's why I'm here. =P

PD: I'm new in this IoC and DI world so try to be easy with me when explaining it :)

© Stack Overflow or respective owner

Related posts about c#

Related posts about simple-injector