Hi Bill,

It definitely passes with 3.5.0.1337, a mock object should return
values as I "expect" the return values, ie if the second expectation
sets up a different value (regardless of the ignored arguments), then
the second call should return that value (It's a different question
though that I probably want to assert on the calls without
"ignorearguments").

cheers,
Andras

On Jan 29, 5:30 pm, bill richards <[email protected]>
wrote:
> Let me try to understand what it is that you want ...
>
> you want the mocking framework to ignore all arguments, and you want
> one object to be returned in the first call and another object to be
> returned in the second call?
>
> I have pasted your code into my IDE and used Rhino v. 3.5.0.1337: It
> fails, so the behaviour between the two versions is actuallly
> consistent.
>
> Changing your test as follows makes the test pass ...
>
>             var mockFactory = MockRepository.GenerateMock<IFactory>();
>             var returnValue1 = new object();
>             var returnValue2 = new object();
>             mockFactory.Expect(f => f.Create(1)).Return(returnValue1);
>             mockFactory.Expect(f => f.Create(2)).Return(returnValue2);
>             var actualReturnValue1 = mockFactory.Create(1);
>             var actualReturnValue2 = mockFactory.Create(2);
>             Assert.AreEqual(returnValue1, actualReturnValue1,
> "returnValue1 and actualReturnValue1 are different");
>             Assert.AreEqual(returnValue2    , actualReturnValue2,
> "returnValue2 and actualReturnValue2 are different");
>
> or the following change makes the test pass:
>
>             var mockFactory = MockRepository.GenerateMock<IFactory>();
>             var returnValue1 = new object();
>             var returnValue2 = new object();
>             mockFactory.Expect(f => f.Create(0)).IgnoreArguments
> ().Return(returnValue1);
>             mockFactory.Expect(f => f.Create(0)).IgnoreArguments
> ().Return(returnValue2);
>             var actualReturnValue1 = mockFactory.Create(1);
>             var actualReturnValue2 = mockFactory.Create(2);
>             Assert.AreEqual(returnValue1, actualReturnValue1,
> "returnValue1 and actualReturnValue1 are different");
>             Assert.AreEqual(returnValue1, actualReturnValue2,
> "returnValue1 and actualReturnValue2 are different");
>
> Now let us imagine why this is the case ....
>
>            .IgnoreArguments().Return(returnValue1)
>
> You have told the mocking framework to IGNORE ALL ARGUMENTS and RETURN
> returnValue1
>
> why would you tell the mocking framework to ignore all arguments if
> you want two different return values? Surely everyone needs some way
> to determine when to return one value over another?

-- 
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