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)?
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.
- 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.
This is awesome. Thanks for your work on this.
Awesome! Great work as always, really like the AAA syntax.
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.
Much appreciated! So many of us benefit from your hard work.
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:
And here is how to use it with good old VB.Net blogs.lessthandot.com/.../vb-net-rhino-mocks-an...
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 ;-)
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?
You released on my birthday. A more vain Tom would suspect that this release is my birthday present. :)
Am I confused here?
AssertWasCalled seems to be hosing when the expected call is made more than once.
... This is working in Rhino Mocks 3.5 SP1 but doesn't seem to be working in the RTM.
Thanks, this makes me happy :-) I'll document it as soon as I have the time for it (probably next week).
Updated with the xml docs
Sorry, some html-looking code got stripped above... the call to GenerateMock should have a type parameter of IFormatProvider.
var mock = MockRepository.GenerateMock<IFormatProvider>();