The Right Way to Do Automocking with Ninject

added by Matt_TCF
9/19/2010 1:45:52 PM


While StructureMap is definitely my IoC container of choice, it’s not the only game in town. At my new job, our existing project uses Ninject. One of my first tasks at this new job was integrating my SpecsFor “framework” into the existing projects. The original version of SpecsFor worked with StructureMap and leveraged its auto-mocking container. While Ninject has an auto-mocking extension, ninject.moq, it is sorely lacking when compared to StructureMap’s offering. In this post, I’ll show you how to modify it into a useful automocking container, and I’ll also show you how easily SpecsFor can be adapted to Ninject using this working container.