Your assumption turns out to be correct. i.e., the function signature needs to change for my tests to pass.
To confirm, I changed my passing test to the following (same input on calls): Expect.Call(idContainer.GetNum1(1)).Return(1); Expect.Call(idContainer.GetNum1(1)).Return(2); This gives me the same error messages as on my failing test cases. So it looks like queued responses is the only way to go. Thanks for the feedback! On Feb 18, 2:23 am, Alex McMahon <[email protected]> wrote: > I think the reason it fails is that without a parameter the signature of the > method for your two calls: > > Expect.Call(idContainer.GetNum2()).Return(1); > Expect.Call(idContainer.GetNum2()).Return(2); > > is the same (in terms of matching it can't use the return). > > I can't quite see why it says "actual #0" I would have thought it would say > "actual #2"... > > If you wanted you could use one expect.call and set repeat.twice on it... > the next question might be how to get it to return 1 then 2, there have been > various discussions about setting up a queue of responses... > > On 16 February 2010 23:20, Frank <[email protected]> wrote: > > > > > I am trying to get my head around the whole ordered replay business. > > So, I wrote a simple test case which, I think, is exposing a bug. > > Specifically, when I setup an ordered sequence of expectations for a > > method without an input but with a return value, the sequence I would > > expect is not returned (and the test always fails). If I add an input, > > however, the ordered API works as expected. > > > To illustrate, I am giving an example for each scenario. The test > > which fails is GetNum2_TestOrderWithoutInput_Success. As far as I > > understand, however, this one should succeed. The exception I get is > > shown below. When using a stub, I see that the return values are > > always 1 for this API. As noted earlier, everything works with > > GetNum1. > > > MyTests.GetNum2_TestOrderWithoutInput_Success: > > Rhino.Mocks.Exceptions.ExpectationViolationException : > > IMyTest.GetNum2(); Expected #1, Actual #0. > > > public interface IMyTest > > { > > int GetNum1(int b); > > int GetNum2(); > > } > > > [Test] > > public void GetNum2_TestOrderWithoutInput_Success() > > { > > var fakeObjEngine = new MockRepository(); > > var idContainer = fakeObjEngine.DynamicMock<IMyTest>(); > > > using (fakeObjEngine.Ordered()) > > { > > Expect.Call(idContainer.GetNum2()).Return(1); > > Expect.Call(idContainer.GetNum2()).Return(2); > > } > > > fakeObjEngine.ReplayAll(); > > > Console.WriteLine(idContainer.GetNum2()); > > Console.WriteLine(idContainer.GetNum2()); > > > fakeObjEngine.VerifyAll(); > > } > > > [Test] > > public void GetNum2_TestOrderWithInput_Success() > > { > > var fakeObjEngine = new MockRepository(); > > var idContainer = fakeObjEngine.DynamicMock<IMyTest>(); > > > using (fakeObjEngine.Ordered()) > > { > > Expect.Call(idContainer.GetNum1(1)).Return(1); > > Expect.Call(idContainer.GetNum1(5)).Return(2); > > } > > > fakeObjEngine.ReplayAll(); > > > Console.WriteLine(idContainer.GetNum1(1)); > > Console.WriteLine(idContainer.GetNum1(5)); > > > fakeObjEngine.VerifyAll(); > > } > > > -- > > 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]<rhinomocks%2bunsubscr...@googlegrou > > ps.com> > > . > > 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.
