Rhino Mocks AssertWasCalled (multiple times) on property getter using AAA

前端 未结 6 1320
半阙折子戏
半阙折子戏 2020-12-30 18:20

I have a mocked object that is passed as a constructor argument to another object.

How can I test that a mocked object\'s property has been called? This is code I am

6条回答
  •  孤独总比滥情好
    2020-12-30 18:53

    I agree with chris answer

    newContact.AssertWasCalled(x => { var dummy = x.Forenames; }, options => options.Repeat.AtLeastOnce());
    

    Additionally If you know exactly how many times the property would be called you can do

    newContact.AssertWasCalled(x => { var dummy = x.Forenames; }, options => options.Repeat.Times(n));
    

    where n is an int.

提交回复
热议问题