I have changed the code to
using( mocks.Record() ) {
login = "aaa";
password = "aaa";
user.login = "aaa";
user.password = "aaa";
IUser u = new User() { access = null, active = false, eMail = null,
errorMsg = null, id = 1, ip = null, isLogged = true,
login = "aaa", name = null, password =
"aaa", firstTime = false, subDomain = null,
timeZoneCompensation = 0.0 };
Expect.Call( service.logOn( ref usuario, login, password ) ).Return
( true ).OutRef(u);
}
But it did not work. When I debug the code I can see then when the
service.logOn method is executed exception is thrown.
Do you have any other idea ???
Thanks in advance
On Feb 11, 10:28 am, Tim Barcz <[email protected]> wrote:
> Try something along these lines...(cannot know this will work for sure as
> you did not provide the whole test case).
>
> Expect.Call(service.logOn("key", ref user, login,
> password)).OutRef(mockedUser);
>
>
>
> On Tue, Feb 10, 2009 at 9:12 PM, mvbaffa <[email protected]> wrote:
>
> > Hi,
>
> > I am new to Rhino Mock and to Mock. I have a method whose signature is
> > like this:
> > public bool logOn( ref user, string login, string password )
>
> > My mock is like this:
>
> > using( mocks.Record() ) {
>
> > login = "aaa";
> > password = "aaa";
> > user.login = "aaa";
> > user.password = "aaa";
> > Expect.Call( service.logOn( ref user, login,
> > password ) ).Return( false );
> > }
>
> > using( mocks.Playback() ) {
> > obj = new TestedObject();
> > obj.testLogOn();
> > }
>
> > The method testLogOn calls the service.logOn. When service.logOn is
> > called from inside testLogOn the values
> > passed to the mocked method service.logOn are exactly the same
> > values expected, listed above.
>
> > When I call mock this method Rhino is returning this:
>
> > Failed testAAA ModelTest Test method ModelTest.UserTest.testAAA
> > threw
> > exception: Rhino.Mocks.Exceptions.ExpectationViolationException:
> > IService.logOn(namespace.user, "aaa", "aaa"); Expected #0, Actual #1.
> > IService.logOn(namespace.user, "aaa", "aaa"); Expected #1, Actual #0..
> > ...
>
> > When I remove the ref parameter from the method logOn. Everything
> > works. I beleive the problem is that when I define the expectation I
> > pass an address of the user object and when I call from inside
> > testLogOn user addres is diferent from the one that was passed to the
> > Expect.Call so Rhino throws the exception.
>
> > What can I do to mock a method like this ???- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---