-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?

System.Exception
  • 247
  • 3
  • 10
  • Moq is a mocking library, not a DI container. – Robert Harvey Nov 28 '09 at 03:57
  • 1
    Can you restate your question in light of the response? Are you looking for DI? If so, what are your candidates? Ninject /StructureMap / Unity ? If mocking, Rhino.Mocks / Moq are the main contenders. You'll get a good answer if you can narrow the question down and/or split it into two. – Ruben Bartelink Nov 30 '09 at 09:45
  • Spring.NET and Typemock are also good alternatives for DI and mocking respectively. – Jeremy McGee Nov 30 '09 at 11:20
  • @JeremyMcGee: Arguably. We need to narrow down what the questioner is looking for and *then* we can debate – Ruben Bartelink Dec 01 '09 at 09:04

1 Answers1

2

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.

Community
  • 1
  • 1
Jeremy McGee
  • 24,842
  • 10
  • 63
  • 95
  • 1
    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 Nov 30 '09 at 22:54