RhinoMock顺序调用

MockRepository mocks = new MockRepository();
ISongBird maleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird)),
    femaleBird = (ISongBird)mocks.StrictMock(typeof(ISongBird));

using (mocks.Ordered())
{
    maleBird.Eat("seeds", 250);
    femaleBird.Eat("seeds", 250);
}

using (mocks.Ordered())
{
    maleBird.Mate(femaleBird);
    femaleBird.Mate(maleBird);
}
mocks.ReplayAll();

maleBird.Mate(femaleBird);
femaleBird.Mate(maleBird);

maleBird.Eat("seeds", 250);
femaleBird.Eat("seeds", 250);
mocks.VerifyAll();

 

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

posted @ 2014-11-13 00:36  HONT  阅读(147)  评论(0编辑  收藏  举报