[英]How to save arguments of function call in Rhino Mocks?
MockRepository mocks = new Rhino.Mocks.MockRepository();
IActiveProgram repository = mocks.CreateMock<IActiveProgram>();
var readPrg = new ReadProgram();
readPrg.init("333", "eee", "", null, repository);
In readPrg.init
I will have a several calls on repository
object. 在
readPrg.init
我将对repository
对象进行多次调用。 For example repository.AddProgram(programName);
例如
repository.AddProgram(programName);
How I will be able to know later on exit from readPrg.init
to know the arguments that my prerecorded function calls been executed. 稍后在
readPrg.init
退出时readPrg.init
知道预记录函数调用已执行的参数。
Thanks for help. 感谢帮助。
You'd call repository.AssertWasCalled(x => x.AddProgram(programName))
after you call init. 调用init后,您将调用
repository.AssertWasCalled(x => x.AddProgram(programName))
。 Look also in the original post of Rhino Mocks AAA syntax 在Rhino Mocks AAA语法的原始帖子中也可以查看
Another option, you could use Expect: 另一种选择,您可以使用Expect:
repository.Expect(x => x.AddProgram(programName)).Repeat.Times(50)
var readPrg = new ReadProgram();
readPrg.init("333", "eee", "", null, repository);
repository.VerifyAllExpectations()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.