ASP.NET MVC : Mocking the Repository with Ninject.Moq

added by teebot
3/3/2010 1:21:27 PM

0 Kicks, 694 Views

If you are already familiar with ASP.NET MVC, you have probably seen the repository pattern in a few examples (such as NerdDinner), maybe you even use it in your own app. One of the most frequent way to hot-plug a Repository class into a controller is to use the Strategy Pattern. But while an application evolves, you might want to centrally manage your wiring within a provider, that's what Dependency Injectors are for. However lots of Dependency Injectors - or IoC containers at large - such as Unity or Castle Windsor contain a plethora of features and often rely heavily on XML configuration, making them overkill for smaller projects. In this short post we will see how to: -Quickly inject a Repository in a controller with Ninject -Mock the IRepository interface in your tests with Ninject.Moq plugin


0 comments