Thanks so much for all the input!! I've refactored the code, so it's not in the same way. I'll have a read and a think of the weekend and if I'm still struggling I'll post a better description and the code next week.
Really appreciate the help and comments from the community! Cheers dave On Oct 2, 12:14 am, Nick John <[email protected]> wrote: > I really just a beginner myself so Tim's advice is of far greater > quality than mine. > However...I'm willing to give it a go. ;-) > > So Presenter is the mock object you have created? You want to set the > values of its Username and Password properties of its View property > and then you are setting the expectation that your object under test > will call the ValidateUser method on your mock Presenter object? > If that is the case then as the error message suggests can't you just > set the View property of your Presenter mock object to be an object > with the right Username and Password properties? > > Sorry if I'm way off the mark. As Tim say's it might be worthwhile > posting your code. > Good luck. > > On Oct 1, 11:26 pm, Dave <[email protected]> wrote: > > > 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 -~----------~----~----~----~------~----~------~--~---
