Ayende @ Rahien

Hi!
My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 5,969 | Comments: 44,489

filter by tags archive

Rhino Mocks 3.5 Gems - Explicit Property Setting Expectations


This post is derived from the Rhino Mocks 3.5 documentation.

Setting expectations for property set was always very simple, and slightly confusing with Rhino Mocks. Here is how you do it:

view.Username = "the user name";	

The problem is that it is hard to see that there is an expectation created here. So, with the generous help of Sebastian Jancke, we have a new syntax:

Expect.Call(view.Username).SetPropertyWithArguments("the user name");

This is much more explicit and easier to understand. We can also set expectation on the property set, without expecting a certain value using this syntax:

Expect.Call(view.Username).SetPropertyAndIgnoreArguments();


Comments

Demis

Yeah much better, intuitiveness over brevity.

Diego Jancic

I prefer to do: Expect.Call(view.Username = "Something")

What's the confusion with that?

Chris

Or Expect.Call(view.Username).SetProperty(value);

Expect.Call(view.Username).SetProperty();

Needless verbosity is noise.

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

  1. Production postmortem: The evil licensing code - 4 hours from now

There are posts all the way to Jul 29, 2015

RECENT SERIES

  1. Production postmortem (5):
    23 Jul 2015 - The case of the native memory leak
  2. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
  3. API Design (7):
    20 Jul 2015 - We’ll let the users sort it out
  4. What is new in RavenDB 3.5 (3):
    15 Jul 2015 - Exploring data in the dark
  5. The RavenDB Comic Strip (3):
    28 May 2015 - Part III – High availability & sleeping soundly
View all series

RECENT COMMENTS

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats