Can I test method call order with AAA syntax in Rhino-Mocks 3.6?

后端 未结 5 1542
南笙
南笙 2020-12-19 01:19

Is it possible to test for the following example if the Method1 called 1st, then Method2 called after and then Method3 by using the AAA syntax, in Rhino-mocks 3.6 ?

5条回答
  •  心在旅途
    2020-12-19 01:43

    Here is how to do it nicely.

    var mocks = new MockRepository();
    var fooMock = mocks.DynamicMock();
    using (mocks.Ordered())
    {
        fooMock.Expect(x => x.Method1());
        fooMock.Expect(x => x.Method2());
    }
    fooMock.Replay();
    
    var bar = new Bar(fooMock);
    bar.DoWork();
    
    fooMock.VerifyAllExpectations();
    

    Found the answer from this blog.

提交回复
热议问题