【发布时间】:2017-03-14 08:30:21
【问题描述】:
我的类中有一个方法,它接收一个函数 (Func) 作为参数:
T Execute<T>(Func<T> func)
{
...
return func();
}
我希望模拟这个类,并让 Moq 调用我发送到 Execute 的函数作为参数。
我怎么称呼Execute:
string result = await executor.Execute(async () => await GetResponse(query));
所以我希望 Moq 调用 GetResponse 并返回其值。我该怎么做?
【问题讨论】:
标签: c# unit-testing moq mstest