Thanks - I changed it to
Expect.Call(Presenter.View.Username).PropertyBehavior().Return
("[email protected]");
Expect.Call(Presenter.View.Password).PropertyBehavior().Return
("password1");
Expect.Call(Presenter.ValidateUser());
But that also gives me an error
System.InvalidOperationException: You are trying to set an expectation
on a property that was defined to use PropertyBehavior.
Instead of writing code such as this: mockObject.Stub(x =>
x.SomeProperty).Return(42);
You can use the property directly to achieve the same result:
mockObject.SomeProperty = 42;
Anything else I can try?
Am I being really simple ? Isn't this a fairly normal use case ?
Thanks
On Oct 1, 12:41 pm, Nick John <[email protected]> wrote:
> Try sticking PropertyBehaviour in:
> Expect.Call(Presenter.View.Username).PropertyBehaviour()Return
> ("[email protected]");
>
> On Oct 1, 8:53 pm, Dave <[email protected]> wrote:
>
> > Hi
>
> > I'm really new to Rhino Mocks and am having some real trouble getting
> > my head around the following problem
>
> > We are building an MVP site and are using Rhino to mock our View
> > implementation. I am currently trying to test that a login control
> > correctly attempts to validate a user. So I have set up my test as
> > follows
>
> > using (mocks.Record())
> > {
> > Expect.Call(Presenter.View.Username).Return("[email protected]");
> > Expect.Call(Presenter.View.Password).Return("password1");
> > Expect.Call(Presenter.ValidateUser()).Return(false);}
>
> > using (mocks.Playback())
> > {
> > //Playback
> > Presenter.SubmitLogin();
>
> > }
>
> > I get the following error
> > System.InvalidOperationException: Previous method
> > 'ILoginBoxView.get_Username();' requires a return value or an
> > exception to throw.
>
> > But I don't really get what it's trying to tell me.
>
> > in psuedo-code, I'm trying to say I expect the View to call Username
> > and Password and return the specified values and I expect that
> > Presenter.ValidateUser() will be called and I want it to return false.
>
> > Can anyone help me clear up what's I'm doing wrong here?
>
> > Thanks
>
> > Dave
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---