【发布时间】:2016-05-13 16:17:53
【问题描述】:
我想弄清楚我在这里缺少什么。我的测试运行良好,但我的 MOQ VerifyAll 抛出异常。
[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;
}
}
以下设置不匹配...
我想知道这是不是因为异步运行的方式我的 MOQ 没有看到模拟对象方法调用?
【问题讨论】:
-
不使用安装程序时会发生这种情况。您将模拟设置为使用
GetActionPlanReferenceList("1"),但称为GetActionPlanReferenceList("1234123")。所以根据起订量你没有使用设置
标签: c# unit-testing asynchronous moq