Request for comments: Changing the way dynamic mocks behave in Rhino Mocks
I have just committed a change to the way Rhino Mocks handles expectations for dynamic mocks and stubs. Previously, the meaning of this statement was "expect Foo() to be called once and return 1 when it does":
Expect.Call( bar.Foo ).Return(1);
Now, the meaning of this is: "expect Foo() to be called one or more times, and return 1 when it does". This means that this will work:
Assert.AreEqual(1, bar.Foo); Assert.AreEqual(1, bar.Foo); Assert.AreEqual(1, bar.Foo);
Where as previously, using dynamic mocks, it would fail on the second assert, because the expectation that was setup was consumed. I think that this is a more natural way to behave, but this is a subtle breaking change.
You can get the old behavior by specifying .Repeat.Once().