Thursday, 3 September 2009

Understanding RhinoMocks better



RhinoMocks is a unit testing tool and:

  • Introduction to RhinoMocks by StephenWalther here.
  • Official Site here.
  • RhinoMocks documentation here.
  • RhinoMocks on WikiBooks here.

Features:

  • You can create a mock object from an interface or a non-static class
  • Set expectations on the called methods by using strongly typed mocks instead of strings unlike NMock

Limitations:

  • RhinoMocks can't mock static and sealed methods and classes (If you have a static class, you must change it; an example is here.)
  • You can't mock a private interface.
  • You need to use Dependency Injection for all the dependencies of your class otherwise you can't mock the dependencies and you can't test your class. What this means is that you have to create an interface for every dependency of a class which you need to test.

No comments: