Skip to content

Ninject – Dependancy Injection you dont want to fight with.

by dotnetdave on June 21st, 2009

Ninject is a Depencancy Injection Container for asp.net, that provides the developer with the tools to decouple the architecture of an asp.net web application. Decoupling is the process of reducing the dependancies between the components of a project. Especaly when the component is used throughout the other components, like logging, utility and data access classes.

I will be using Ninject in the near future to allow mocking of a data access class in a new project. This will allow me to use a common interface to create two data access classes one of which talks to the application database and the other that uses the Rhino Mocks framework coupled with Ninject to substitute a fake data access class into the application and run the unit tests against it. This ensures that I am testing the code in my application rather than the connection to the database and the data. But what about testing the database I hear you cry. I will be using another set of unit tests to test the real data access class which includes testing the connection and expected results from the database.

Back to Ninject. I have had a look at the syntax and have looked at some of David Hayden’s posts on Ninject which all seam quite simple and easy to understand. I will let you all know how it turns out.

From → ASP.Net

3 Comments
  1. Kevin Sparrow permalink

    Hey Dave, be interested to hear howthisgoes, been using Nunit but I could do with a substituted data layer.

  2. Gavin Ingram permalink

    Definitely agree with what you stated. Your explanation was definitely the simplest to understand. I tell you, I generally get irked when folks focus on problems that they plainly don’t know about. You managed to hit the nail correct about the head and explained out everything without complication. Perhaps, people can take a signal. Will likely be back again to get more. Many thanks

Trackbacks & Pingbacks

  1. Topsy Pingback

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS