Planning the next version of Rhino Mocks
I've been thinking about what needs to be add to Rhino Mocks feature-wise. I spoke with several developers who are using it and I think that I need to add the following:
Relaxed mocks - a mock object that allows to set expectations on it, but doesn't care about unexpected calls. This mean that any unexpected call (in the replay state) would be ignored (but you could setup actions for it. throwing or returning a value). Any calls that you does setup expectation for will be verified. So you can say: "Create a mock object and make sure that the method Foo() is called with these parameters twice and return that. Oh, and if method Bar() is called, throw an exception. Anything else you can just ignore."
This should be useful where there for those cases where you just need to verify some action, and you don't care whatever else also happens. It can translate to great savings in setup code. This would require some changes in the way I verify actions during runtime, but I believe that it should be a matter of simply adding a new ReplyMockState (and perhaps a new RecordMockState to ensure that the right replay state is achieved).
Another thing it would require is to add ExpectNoCall() method to the IMethodOptions, to allow the exclusion of a method from the ignored list.
Stub object - This is a relaxed mock that is created and returned already in the replay state, so you could immediately use it.
Add VerifyMockState - Just to ensure that you won't call anything that has been verified already. This would cause a verified object to raise an exception with "object verified" message instead of unexpected call.
If you can think of anything else, let me know.
Comments
Comment preview