MockRepository mocks = new MockRepository();
ISongBird maleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird)),
femaleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird)); using (mocks.Ordered())
{
maleBird.Eat("seeds", );
femaleBird.Eat("seeds", );
} using (mocks.Ordered())
{
maleBird.Mate(femaleBird);
femaleBird.Mate(maleBird);
}
mocks.ReplayAll(); maleBird.Mate(femaleBird);
femaleBird.Mate(maleBird); maleBird.Eat("seeds", );
femaleBird.Eat("seeds", );
mocks.VerifyAll();

总之用Ordered就可以次序调用了,上面是官方的例子。

05-11 20:48