views:

311

answers:

1

Faced with choosing a Dependency Injection Framework in a historically MS shop working with C#, I'm interested in finding out the differences between Moq and Unity.

Some of the main concerns would include:

  • Ease of use for developers with no background in DI
  • Feature comparison between the two (once everyone becomes familiar with the technology).
  • Performance (not sure if this is even an issue)
  • Integration with visual studio, particularly with regards to refactor tools
  • Readability / maintainability
  • Experience when used with other tools such as MEF or EF

Has anyone had any experience in comparing these two? Does anyone have any reasons for choosing one or the other? Are there any others that I should really be considering as well?

+2  A: 

As stated by Robert Harvey, Moq is a library for mocking (i.e. replacing a class implementation with one that always returns predictable results), not a dependency injection framework.

You might use Moq with Unity.

For alternative DI suggestions, try here.

Jeremy McGee
Thanks for the clarification guys.I was actually looking for a DI framework and had considered Unity amongst a few others including Castle Windsor (http://www.castleproject.org/container/index.html). It was then that someone suggested that I consider Moq which is where the confusion started as I couldn't find any comparison between Unity and Moq (which makes sense now).
System.Exception