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();

Print | posted on Thursday, October 09, 2008 9:48 AM

Feedback


Gravatar

# re: Rhino Mocks 3.5 Gems - Explicit Property Setting Expectations 10/9/2008 2:25 PM Demis

Yeah much better, intuitiveness over brevity.


Gravatar

# re: Rhino Mocks 3.5 Gems - Explicit Property Setting Expectations 10/10/2008 5:48 AM Diego Jancic

I prefer to do: Expect.Call(view.Username = "Something")
What's the confusion with that?


Gravatar

# re: Rhino Mocks 3.5 Gems - Explicit Property Setting Expectations 10/13/2008 4:42 PM Chris

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

Needless verbosity is noise.

Comments have been closed on this topic.