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,007 | Comments: 44,762

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.


No future posts left, oh my!


  1. Speaking (3):
    23 Sep 2015 - Build Stuff 2015 (Lithuania & Ukraine), Nov 18 - 24
  2. Production postmortem (11):
    22 Sep 2015 - The case of the Unicode Poo
  3. Technical observations from my wife (2):
    15 Sep 2015 - Disk speeds
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series



Main feed Feed Stats
Comments feed   Comments Feed Stats