【发布时间】:2011-12-05 08:48:33
【问题描述】:
如何强制 RhinoMocks 中的存根对象为它的 void 方法返回 void?
举个例子:
public interface ICar
{
string Model {get;set;}
void Horn();
}
ICar stubCar= MockRepository.GenerateStub<ICar>();
stubCar.Expect(c=>c.Horn()).Return( //now what so that
// it returns nothing as the meth. returns void ?
【问题讨论】:
-
如果它定义为 void 返回类型,那么它如何返回任何东西?
-
我担心的是,如果我不强制它返回 void,对这个存根的调用将引发异常。我试过了,发现:乔恩是对的!
标签: c# unit-testing mocking rhino-mocks