Over the past few months on the RhinoMocks group I have seen several good ideas for enhancements to the library. One of the ideas was to add a DoNotExpect.Call helper, which would do the same thing as the LastCall.Repeat.Never() syntax, just in a much more concise way.
This past weekend I added the DoNotExpect.Call() syntax to RhinoMocks, and Ayende has already applied the patch to the RhinoMocks trunk. Here's how you use the new syntax:
IService svc = mocks.DynamicMock<IService>();
DoNotExpect.Call(svc.Load("Sneal"));
DoNotExpect.Call(delegate { svc.Save("Sneal"); });
There are two overloads for the method, one takes an object, and the other a delegate. For methods that return a value you can use the simpler one without the delegate, however for void methods you need to use the delegate syntax (since something has to be passed in, even if it is technically ignored).
I'm excited about the syntax since I know I will use it quite often on my controller tests that use a lot of dynamically mocked objects. The syntax I think is also easier to understand, especially for RhinoMocks newbies who have used NMock2 before.
Hopefully I'll have time to add some other enhancements to RhinoMocks in the near future. It feels good to give back to the software ecosystem every once in a while.
Powered by: newtelligence dasBlog 2.1.8102.813
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2010, Shawn Neal
E-mail