I play around a little and had to "temporarily" go back to record/play
semantics to get this working.  Here's a little test I did:

var wasCalled = false;

var view = MockRepository.GenerateMock<IMyGridView>();
view.BackToRecord();
Expect.Call(view.FilterCriteria).SetPropertyAndIgnoreArgument().WhenCalled(p
=> wasCalled = true);
view.Replay();

var ds = new DoSomething(view);
ds.Foo();

Assert.IsTrue(wasCalled);

Foo simply looks like this:

public class DoSomething
{
        private readonly IMyGridView view;

        public DoSomething(IMyGridView view)
        {
                this.view = view;
        }

        public void Foo()
        {
                view.FilterCriteria = "abc";
        }
}

Hope this helps.

---
Patrick Steele
http://weblogs.asp.net/psteele



On Tue, Dec 21, 2010 at 8:35 AM, kbaltrinic <[email protected]> wrote:
> This is a repost of some one else's question on StackOverflow (http://
> stackoverflow.com/questions/4116361/stub-property-setter-with-rhino-
> mocks-to-execute-an-action-when-called), but I did not see a workable
> AAA answer there so I am hoping for a better response here.
>
> How do you correctly do the following:
>
>  _view = MockRepository.GenerateMock<IMyGridView>();
>  _view.Stub(v => v.FilterCriteria == null).IgnoreArguments()
>                .WhenCalled( ... do something ... );
>
>
> In my case I am trying to do this because I need to assert a correctly
> ordered sequence of actions taken on the view, one of which is a call
> to set the FilterCriteria.
>
> --Regards,
> Ken
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Rhino.Mocks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rhinomocks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to