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].
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en.