Rhino Mocks 3.5 Release Candidate

time to read 3 min | 448 words

Well, after a much longer beta period, and getting some very valuable input, Rhino Mocks 3.5 is out in Release Candidate. I am putting this out as RC, but I am pretty sure that those bits would be the RTM version as well.

The only major task left is to start documenting the changes. The move to 3.5 has made a lot changes in approach that I recommend to use (note that the API is compatible with 3.4).

I would like to thank Jordan Terrell, David Tchepak, Stefan Steinegger, Jason Meckley, Scott Brady, Ernst Naezer, Roelof Blom and Aaron Jensen for helping me get this out the door.

The changes (from 3.4) are:

  • Assert Act Arrange syntax, of course.
  • Better handling of exception in raising events from mock objects
  • Fixing an issue with mock objects that expose methods with output parameter of type System.IntPtr.
  • Allowing to return to record mode without losing expectations.
  • Inline constraints:
  • [Test]
    public void WhenUserForgetPasswordWillSendNotification_WithConstraints()
        var userRepository = MockRepository.GenerateStub<IUserRepository>();
        var notificationSender = MockRepository.GenerateStub<INotificationSender>();
        userRepository.Stub(x => x.GetUserById(5)).Return(new User { Id = 5, Name = "ayende" });
        new LoginController(userRepository, notificationSender).ForgotMyPassword(5);
        notificationSender.AssertWasCalled(x => x.Send(Arg.Text.StartsWith("Changed") ));
  • CreateMock() is deprecated and marked with the [Obsolete] attribute. Use StrictMock() instead.
  • Fixed an issue with merging, would cause issues if you are also using Castle Dynamic Proxy.
  • Fixed various typos
  • Better error handling for AAA syntax abuse
  • Will give better errors if you call Verify on a mock that is in record mode.
  • BackToRecord extension method.
  • Can mock interfaces with modopt params.
    • If you don't know what this means, it means that you can now mock interfaces that C++/CLI generates under some conditions (mixing native types with CLR types). This is probably the longest standing bug in Rhino Mocks.
  • Fixed issue with mocking internal classes and interfaces.
  • Full XML documentation
  • New event raising syntax:
    eventHolder.Raise(stub => stub.Blah += null, this, EventArgs.Empty);
  • AAA syntax now works with Ordering
  • Better error message if trying to use SetupResult on stubbed mock properties.

There are a lot of goodies in this release.

I am starting to create the documentation for this release here. This is a wiki, any help would be appreciated.

You can get the new version, for both 3.5 and 2.0 from the download page.