【发布时间】:2016-10-23 06:35:22
【问题描述】:
我在服务中有以下方法,但我未能在我的单元测试中调用它。该方法使用async/ await 代码,而且(我认为这是导致我出现问题的原因)具有带有点符号的方法名称,老实说,我不确定它有什么作用?请参阅下面的示例
实施
async Task<IEnumerable<ISomething>> IMyService.MyMethodToTest(string bla)
{
...
}
单元测试
[Fact]
public void Test_My_Method()
{
var service = new MyService(...);
var result = await service.MyMethodToTest(""); // This is not available ?
}
更新
已尝试建议,但无法编译并显示以下错误消息
await operator can only be used with an async method.
【问题讨论】:
-
IMyService.MyMethodToTest 暗示 MyMethodToTest 是接口 IMyService 的方法 MyMethodToTest 的实现
标签: c# .net interface xunit explicit-implementation