我正在尝试通过相应的Lambda表达式在实例上伪造一个方法:
private void TranslateCallbackToSetup<TResult>(Mock<TService> stubService, IMethodCall<TService,TResult> methodCall)
{
stubService.Setup(t => methodCall.RunMethod(t)).Returns(() =>
{
return default(TResult);
});
}
public interface IMethodCall<in TService, out TResult> : IMethodCall where TService : class
{
Func<TService, TResult> RunMethod { get; }
}
语法似乎没问题,但代码出现了ArgumentException:
表达式不是方法调用:t => t
有什么想法吗?