IoC containers are great. They take away the burden of having to create dependencies before using things, and when your dependencies start to become complex and you have a whole graph of them, it can get ugly if you’re not using one. So to the rescue comes Mr. Unity, Mr. StructureMap, Don AutoFac or the Hero Ninject. Take your pick.
But all this greatness can come back and bite you on the tip of your pinky finger (the one on the right hand). Why is that?
Let’s assume you have the following class:
and you decide to introduce a new dependency
That code will compile, as will any other code throughout the project that is using CustomerServices. It’s only then when the container tries to resolve CustomerServices, will it see that you have not registered any type for IAuditingServices. And this happens at runtime.
So it’s important to create configuration tests for your containers.