我有一个我正在测试的课程.此类使用接口中的take作为构造函数参数.此接口具有一个具有out参数的方法.
我想要做的是模拟这个方法,以便out参数始终是一个特定的值.
如何才能做到这一点?
要执行此操作,只需创建具有所需值的本地并在该out位置使用该值.
int theValue = 42;
Mock<ITarget> target = ...;
target.Setup(x => x.TheMethod(out theValue));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1561 次 |
| 最近记录: |