unit-testingnhibernaterhino-mocksrepositoryrhino-commons

How do you mock UnitOfWork from Rhino.Commons?


My application is using Rhino.Commons - NHRepository and UnitOfWork. I like the With.Transaction() syntax for transactions and have been using it for some time.

But I ran into a problem - how do I mock a UnitOfWork for testing? Especially this is causing trouble for me:

With.Transaction(() => Repositories.TwinfieldSpooler.Update(spool));

I can mock repositories with Rhino.Mocks, but how can I easily mock UnitOfWork for this kind of code?


Solution

  • Thanks, but I've actually decided to ignore mocking of the Rhino infrastructure. I found this post by Ayende http://ayende.com/Blog/archive/2009/04/28/nhibernate-unit-testing.aspx on using a sqlite database rebuilt with every test. This has been a great solution!