MockRepository mocks = new Rhino.Mocks.MockRepository();
IActiveProgram repository = mocks.CreateMock<IActiveProgram>();
var readPrg = new ReadProgram();
readPrg.init("333", "eee", "", null, repository);
在readPrg.init
中,我将对repository
个对象进行多次调用。
例如repository.AddProgram(programName);
稍后我会从readPrg.init
退出时知道我预先记录的函数调用已执行的参数。
感谢您的帮助。
答案 0 :(得分:1)
调用init后,您将调用repository.AssertWasCalled(x => x.AddProgram(programName))
。另见the original post of Rhino Mocks AAA syntax
另一种选择,你可以使用Expect:
repository.Expect(x => x.AddProgram(programName)).Repeat.Times(50)
var readPrg = new ReadProgram();
readPrg.init("333", "eee", "", null, repository);
repository.VerifyAllExpectations()