Ayende @ Rahien

It's a girl

Rhino Mocks 3.5 RTM

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)?

Features:

  • 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.

Patches:

  • 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.

Improvements:

  • 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.

Comments

Tim Barcz
10/05/2008 12:10 AM by
Tim Barcz

Oren,

This is awesome. Thanks for your work on this.

jdn
10/05/2008 12:47 AM by
jdn

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

Stefan Lieser
10/05/2008 12:53 PM by
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.

Cheers,

Stefan Lieser

Jason Alexandrian
10/05/2008 03:05 PM by
Jason Alexandrian

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

Alex Scordellis
10/06/2008 09:04 AM by
Alex Scordellis

Oren,

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:

using.stormwindproject.org:8081/.../viewpage.ac...

Thanks,

Alex

Stefan Steinegger
10/06/2008 02:40 PM by
Stefan Steinegger

Ayende,

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
10/06/2008 07:02 PM by
Ayende Rahien

Stefan,

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
10/06/2008 07:18 PM by
Tom Opgenorth

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

Dave Foley
10/06/2008 09:13 PM by
Dave Foley

Am I confused here?

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

    [Test]

    public void Rhino_3_5_Release_Issue() {

        var mock = MockRepository.GenerateMock

<iformatprovider();

        mock.GetFormat(typeof(string));

        mock.GetFormat(typeof(string));


        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
10/07/2008 10:15 AM by
Stefan Steinegger

Ayende,

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

Dave Foley
10/07/2008 03:05 PM by
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();

Comments have been closed on this topic.