Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,128 | Comments: 45,548

filter by tags archive

Rhino Mocks 3.5 RTM

time to read 3 min | 492 words

Today I decided that I had enough time to get bugs for the 3.5 RC, so I fixed all the remaining bugs, updated the Rhino Mocks 3.5 Documentation, and put the binaries out the site.

For this release, I actually have 4 binary packages. One for .NET 3.5 and one for .NET 2.0, but I have an additional criteria, with the castle assemblies merged (default) and with the castle assemblies included). The reason for having those two options is that people who want to extend Rhino Mocks directly can do it more easily. In general, I suggest using the merged version.

So, what do we actually have here (feature differences from 3.4)?


  • Assert Act Arrange syntax for mocking
    • Including support for .NET 2.0
  • Added a way to access the mocked method at runtime, using WhenCalled (similar to Do(), but without the pain of having to specify a special delegate).
  • CreateMock() is deprecated and marked with the [Obsolete] attribute. Use StrictMock() instead.
  • Support for mocking interface in C++ that mix native and managed types. (Note, may require that you install kb957541 to get around bug introduced to the framework on SP1).
  • New event raising syntax:
    eventHolder.Raise(stub => stub.Blah += null, this, EventArgs.Empty);
  • Better support for multi threaded replays.
    • Note that access to the mock object is now serialized.
  • Support AssertWasCalled on parial mocks.


  • From Sebastian Jancke, adding support for SetPropertyAndIgnoreArguments() and SetPropertyWithArguments( o );
  • From Yann Trevin, adding support for List.Element("MyKey", ...), so we are not limited to just integers.
  • From David Tchepak, adding support for ctor arguments when creating a mock using static method.
  • From Stefan Steinegger - much better support for creating inline constraints.


  • Better handling of exception in raising events from mock objects
  • Better error message when trying to set expectation on properties of a stub.
  • Better error handling for AAA syntax abuse
  • Will give better errors if you call Verify on a mock that is in record mode.
  • Allowing to return to record mode without losing expectations.
  • BackToRecord extension method.
  • AAA syntax now works with Ordering
  • Better error message if trying to use SetupResult on stubbed mock properties.
  • Better error message when trying to mock null instance.

Bug fixes:

  • Fixing an issue with mock objects that expose methods with output parameter of type System.IntPtr.
  • Fixed an issue with merging, would cause issues if you are also using Castle Dynamic Proxy.
  • Fixed various typos
  • Fixed issue with mocking internal classes and interfaces.
  • OutRef params was not copied when creating new expectation from an existing one.
  • Fixing an issue with leaking expectationReplaced in mocks.


Tim Barcz


This is awesome. Thanks for your work on this.


Awesome! Great work as always, really like the AAA syntax.

Stefan Lieser

Oren, great work! Thank you so much for giving us Rhin Mocks!

The Rhino-Mocks-net-3.5-v3.5.zip is missing the xmldoc file.


Stefan Lieser

Jason Alexandrian

Much appreciated! So many of us benefit from your hard work.

Alex Scordellis


Thanks for the new build, with the unmerged Castle assemblies.

If your blog permits you, is there any chance that you could please replace the link "extend Rhino Mocks" directly with the following? It much better explains what we're up to with NSynthesis and how it relates to Rhino Mocks:




Stefan Steinegger


Thanks a lot for all this great new features! Rhino Mocks are essential for our tests and the new features will make our life (even) much easier.

I know that my contribution has been ridiculously small compared to the time and work others spent on Rhino Mocks. Regardless I'm proud of the inline constraints and hoped so much to be mentioned as a contributor ;-)

Ayende Rahien


The post was updated, I am sorry for not attributing the change to you. I certainly appreciate the effort you went to in order to add the feature.

By the way, can you review and edit the wiki page about this feature?

Tom Opgenorth

You released on my birthday. A more vain Tom would suspect that this release is my birthday present. :)

Dave Foley

Am I confused here?

AssertWasCalled seems to be hosing when the expected call is made more than once.


    public void Rhino_3_5_Release_Issue() {

        var mock = MockRepository.GenerateMock




        mock.AssertWasCalled(x => x.GetFormat(typeof(string)));


... This is working in Rhino Mocks 3.5 SP1 but doesn't seem to be working in the RTM.

Stefan Steinegger


Thanks, this makes me happy :-) I'll document it as soon as I have the time for it (probably next week).

Dave Foley

Sorry, some html-looking code got stripped above... the call to GenerateMock should have a type parameter of IFormatProvider.

var mock = MockRepository.GenerateMock();

Comment preview

Comments have been closed on this topic.


  1. The low level interview question - 4 hours from now
  2. The worker pattern - 3 days from now

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series



Main feed Feed Stats
Comments feed   Comments Feed Stats