Stubbing problems with Rhino Mocks


Stubbing problems with Rhino Mocks

I’ve been doing a fair amount with Rhino Mocks lately, and found that it doesn’t support one common scenario well.

You have an interface with several read-only properties (get accessors but no set accessors). You want to stub that interface.

It appears that you have to actually create a MockRepository rather than just using the static method to create the stub. You then have to call SetupResult.For on the properties, and put the repository instance into replay mode. Worse, you then can’t change the results (as far as I can tell). This makes it more difficult to define setup fixtures and the like.

I’m hoping Rhino Mocks v3.5 will resolve this issue. If it doesn’t, I may be looking for a new mocking framework.

Update - September 7, 2008

Please see Ayende’s comment.

Your Host:
Copyright © 2000-2013 by William Sorensen. All rights reserved.