Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing Rhino Mocks-如何断言一个被模拟的方法被调用了n次?_Unit Testing_Tdd_Rhino Mocks - Fatal编程技术网

Unit testing Rhino Mocks-如何断言一个被模拟的方法被调用了n次?

Unit testing Rhino Mocks-如何断言一个被模拟的方法被调用了n次?,unit-testing,tdd,rhino-mocks,Unit Testing,Tdd,Rhino Mocks,我如何断言模拟对象上的方法被精确调用了n次 以下是控制器操作的代码片段,我想测试: for (int i = 0; i <= newMatchCommand.NumberOfMatchesToCreate; i++) { serviceFacade.CreateNewMatch("tester", Side.White); } for(inti=0;i尝试Expect.Call(方法)。重复.Times(n)更好的方法是: mockObject.AssertWasCalled(x

我如何断言模拟对象上的方法被精确调用了n次

以下是控制器操作的代码片段,我想测试:

for (int i = 0; i <= newMatchCommand.NumberOfMatchesToCreate; i++) {
    serviceFacade.CreateNewMatch("tester", Side.White);
}
for(inti=0;i尝试
Expect.Call(方法)。重复.Times(n)

更好的方法是:

mockObject.AssertWasCalled(x => x.SomeMethod(), opt => opt.Repeat.Times(n));
VerfiyAll()期望您返回一个对象,它抱怨您期望返回一些东西