• ASP.NET MVC

    Posted on August 29th, 2008

    Written by Emad Ibrahim

    Tags

    , , , , , ,

    Is this Better than Constructor Injection?

    So after I finished my post on property injection I thought of something, maybe I shouldn’t use constructor injection for my classes.  Maybe, I can just use lazy properties that would call my IoC (Ninject) Kernel to instantiate the object.  So instead of defining a constructor like this: public IAccountService Service { get; set; } [...]

  • ASP.NET MVC

    Posted on August 29th, 2008

    Written by Emad Ibrahim

    Tags

    , , , , , , ,

    Property Injection in ASP.NET MVC with Ninject

    I got a design challenge with asp.net mvc.  I want to keep track of the currently logged in user in the session because I don’t want to hit the database every time I need to get the username or id for a query.  And I have all my controllers inherit from a base controller named [...]

  • ASP.NET MVC, Programming, Testing

    Posted on August 27th, 2008

    Written by Emad Ibrahim

    Tags

    , , , , , , , , ,

    Mocking and Dependency Injection in ASP.NET MVC

    Here is the situation, my controller constructors take multiple interfaces as parameters.  I do this in order to use constructor injection which allows me to inject the controllers with mocked objects in my unit tests. For example, my AccountController takes IEmailService, IFormsAuthentication and MembershipProvider (abstract class) as parameters. During my testing, I want to mock [...]

  • ASP.NET MVC, Programming

    Posted on August 21st, 2008

    Written by Emad Ibrahim

    Tags

    , , , , , , , , ,

    Ninject: Killer IoC

    In my previous post, The Best IoC Container, I decided to go with StructureMap as the framework of choice.  I received a comment telling me to check out Ninject and then a day or two after, I saw Corey Gaudin’s post on using Ninject with MVC, so I decided to try it out. It wasn’t [...]