Stubbing problems with Rhino Mocks

09/04/08

Permalink 09:08:29 pm, by truewill Email , 131 words, 169 views   English (US)
Categories: Testing

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.

Comments, Pingbacks:

Comment from: Ayende Rahien [Visitor] Email · http://www.ayende.com/Blog/
SetupResult.For is for constant results, if you use that, the result will always be returned.

If you want to change values after calls, you need to use Expect.Call()
PermalinkPermalink 09/05/08 @ 04:55

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
The name truewill is composed of two other words. What is the SECOND word?

Development Central

Development Central is the blog of Bill Sorensen, a professional software developer. Much of this will relate to C#, .NET, and OOP in general.

Disclaimer
These postings are provided "AS IS" with no warranties and confer no rights.

Search

Categories

Linkblog

b2evolution

contributors

XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 5

powered by b2evolution free blog software