Ayende @ Rahien

It's a girl

Rhino Mocks 3.6

This release is mostly to put out all the patches & fixes that went into Rhino Mocks since the 3.5 release, almost a year ago.

The changes from the previous version are:

  • Dynamic mocks and stubs will now assume that a call is match by any number of expectation.
  • Recursive mocks (with help from webpaul)
  • Fixing an issue with ArgManager in multi threaded scenarios (patch from Stefan Steinegger)
  • Fixing problem with IgnoreArguments() after Do() erasing the Do()
  • Fixing an issue with SetPropertyWithArgument improperly using LastCall.
  • Allowing Rhino Mocks to raise events on VB6 dlls.
  • Adding support for AssertWasCalled for getters (patch from robin clowers)
  • Adding remoting mocks as static methods (patch from Peter Mounce)
  • Adding a way to access the method from MethodInvocation
  • Fixing an issue with recursive return types when making a call to record an event more than once.
  • Various spelling & grammar issues (patch from Peter van der Woude)
  • Fixing an issue with stubbing MarshalByReferenceObjects
  • Better integration with Pex
  • Making LambdaConstraint work better with polymorphic args
  • Better feature parity for AAA with Record & Playback: Partials, Multis, and Stricts
  • Fixing an issue with stubbing properties of generic interfaces implemented twice using different generic parameters (Alexander Groß)

As usual, the download is here.


09/01/2009 11:40 AM by

as a Moq user how would you "sell" Rhino Mocks to me (no offense, just currious)?

I somehow skipped RhinoMocks (wasn't tdd guy before) but it already went away with the record-replay, and the 2 frameworks seems identical...so can you be a good salesman and persuade me to use it?

Rhino is your baby so I would like to have some comparison between the two. (I know google will spit something out but...)

or you can be a diplomat and say "try it, you'll love it" :D

Ayende Rahien
09/01/2009 11:44 AM by
Ayende Rahien


I wouldn't, use whatever fits your needs

09/01/2009 12:31 PM by

I'm a little confused probably:

"Dynamic mocks and stubs will now assume that a call is match by any number of expectation."

Does this mean that from now on: myMock.Stub(...) == myMock.Stub(...).Repeat.Any()

and: myMock.Expect(...) == myMock.Expect(...).Repeat.Any() ?

Shane Courtrille
09/01/2009 03:42 PM by
Shane Courtrille

I'd sell you on Rhino Mocks by saying it doesn't do a MyMock.Object to get at the actual object. From what I've heard that's the main complaint.

I'd sell you on Moq by saying the API usage is MUCH cleaner. There aren't N ways to do one thing.

I'm still hoping that at some point we see a Rhino Mocks release that removes backwards compatibility for everything not AAA.

09/01/2009 08:37 PM by

Shane, +1 to hoping for a release one day that removes the record/replay syntax.

It doesnt bother me, but I think its definitely an issue for getting new users on board

Noam Gal
09/02/2009 06:30 AM by
Noam Gal

I tried dropping in 3.6 over my 3.5 in a .NET 2.0 project. Apparently I now need system.core.dll 3.5 for the RhinoMocksExtensions calls.

Is it a conscious decision to stop supporting 2.0, or am I missing something?

Ayende Rahien
09/02/2009 10:18 AM by
Ayende Rahien


3.6 doesn't support 2.0 anymore

Noam Gal
09/02/2009 10:35 AM by
Noam Gal

Something worth mentioning...

In any case, I did manage to get it to run on my 2.0 project. Only had to add the above reference (I do have 3.5 installed). So far it worked, though I am not doing a whole lot of stuff with it yet, so maybe it'll fail on more complex scenarios.

The recursive mocks are very nice indeed.

09/02/2009 11:33 AM by

Sounds like a test-breaking change. I'd say that would be ok for Stub but is too much change for Expect, but I'd also say to keep the behavior of both as similar as possible...

Any specific reasons for this?

Ayende Rahien
09/02/2009 11:36 AM by
Ayende Rahien

It was the expected behavior from the users point of view.

Kurt Harriger
09/03/2009 05:34 PM by
Kurt Harriger


I had a few dozen tests fail after upgrading to v 3.6 from code like this:

var mocks = new MockRepository();

var something = mocks.Stub <isomthing();

something.Stub(x=>x.DoSomething() ).Return(true);


The root cause of the problem appears that mock.Stub/Mock/etc no longer returns the mock in replay mode. To fix replaced mock.Stub with MockRepository.GenerateStub.

Ayende Rahien
09/03/2009 06:50 PM by
Ayende Rahien


That is actually expected, that should have never worked, you are mixing the two styles of working together

Jiho Han
09/03/2009 10:32 PM by
Jiho Han

w.r.t. .net 2.0 support, I tried to download v3.5 for 2.0 but they still required System.Core.dll

Like, Noam above, do I need to add reference to System.Core.dll in my 2.0 project?

09/08/2009 03:12 PM by


Just to let you know that I'm having problems with rhino mocks 3.6 and nunit 2.5.*

I'm running nunit console using a project file containing 20 assemblies. All tests pass but it fails with the following:

Unhandled Exception:

System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.

at System.AppDomain.get_FriendlyName()

at NUnit.Util.DomainManager.DomainUnloader.Unload()

at NUnit.Util.DomainManager.Unload(AppDomain domain)

at NUnit.Util.TestDomain.Unload()

at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)

at NUnit.ConsoleRunner.Runner.Main(String[] args)

I can get it to succeed if I take out some of the assemblies under test but never consistently the same assembly so it doesn't look like my code. All assemblies are targeting 3.5. If I revert back to nunit 2.4.7 everything works fine.

It might be something to do with nunit but I thought I'd let you know.

Ayende Rahien
09/08/2009 04:12 PM by
Ayende Rahien

It is an NUnit thingie.

We had the same problem with Castle

Comments have been closed on this topic.