关于[Unit testing Autofac registrations]的摘要:
We use Autofac as our IoC container at Konstrukt, so we can easily mock dependencies when unit testing, allow for more flexibility and general decoupling. All the normal stuff you would expect with IoC and dependency injection. Fore the most part, I’ve been very pleased with Autofac, and I’m a big fan of Dependency Injection and Inversion of Control. But, in a test-driven environment, where we mock out the dependencies further down the tree, we often get scenarios where we forget to register the types and interfaces in our modules (and container), only to be surprised by runtime errors and exceptions. Registering all classes with matching interfaces in dependent assemblies in an automated manner is not an option, as the interfaces aren’t always header interfaces, and we don’t want to add more registrations than we need, and a few other reasons.