2
我想弄清楚我在这里错过了什么。我的测试运行良好,但最小起订量VerifyAll
正在抛出异常。MOQ错误设置与异步/等待单元测试不匹配
[TestMethod]
public async Task ActionPlanDataProvider_GetActionPlanReferenceList_ReturnsValid()
{
try
{
//Arrange
Mock<IActionPlanDataProvider> moqAPlan = new Mock<IActionPlanDataProvider>();
//moqAPlan.Setup(x => x.GetActionPlanReferenceList()).ReturnsAsync(new ActionPlanReferenceList());
moqAPlan
.Setup(x => x.GetActionPlanReferenceList("1"))
.Returns(Task.FromResult(new ActionPlanReferenceList()));
//Act
var d = await moqAPlan.Object.GetActionPlanReferenceList("1234123");
//Assert
moqAPlan.VerifyAll();
}
catch (Exception ex)
{
string a = ex.Message;
throw;
}
}
以下设置不匹配...
我不知道这是否是因为异步的方式运行,我的起订量不看嘲笑对象的方法调用?
的是,当不使用安装情况。你设置模拟使用'GetActionPlanReferenceList(“1”)',但叫做'GetActionPlanReferenceList(“1234123”)'。所以根据moq你没有使用设置 – Nkosi