我需要存根的方法的调用方式如下:
List<DocumentInfo> documentInfosToDelete = await _documentInfoRepository.GetListByExternalIdAsync(
partyLegalEntity,
externalId,
type,
status);
Run Code Online (Sandbox Code Playgroud)
这有效,但会生成编译器警告:“此异步方法缺少‘等待’运算符”等。
testService.DocumentInfoRepos.GetListByExternalIdAsyncStringStringDocumentTypeDocumentStatus =
(async (a, b, c, d) =>
{
GetListByExternalIdAsyncCalled = true;
return new List<DocumentInfo>();
});
Run Code Online (Sandbox Code Playgroud)
我想摆脱这些警告,因为它们会淹没任何有关实际问题的警告。
返回 new Task(...) 挂起。如果我正确理解了我在 WWW 上找到的内容,Task.Run(...) 所做的事情与我们正在使用的等待异步模式完全不同。
该怎么办?