【发布时间】:2010-12-29 12:24:53
【问题描述】:
我正在使用 RhinoMocks 编写单元测试来模拟,现在我需要一些我以前没有使用过的新功能。
我想调用一个函数,它又会调用一个异步函数。为了模拟异步函数完成并使用执行结果触发给定的回调,我假设我可以使用 RhinoMocks 中的回调功能,但我该怎么做呢?
基本上我想做的是这样的:
fakeSomething = MockRepository.GenerateMock<ISomething>();
fakeSomething.FictionousFunctionSettingCallback(MyFunctionCalled, MyCallback, theParameterToGiveCallback);
var myObj = new MyClass(fakeSomething);
myObj.Foo();
// Foo() now fires the function MyFunctionCalled asynchronous,
// and eventually would trigger some callback
所以;是否有一个真正的功能可以替换这个“FictionousFunction”来设置它?请问这是否不清楚..
【问题讨论】:
标签: c# unit-testing mocking rhino-mocks