1

有人建议我在 Mocking 之后测试一些方法。我必须像 5 一样多次运行这个模拟。我想知道它是否可以在 lambda 表达式中完成,或者我必须循环它。谢谢

//when you know the parameter values to expect
mockEmailRequest.Verify(r=>r.EmailRecevied(expectedEmail, expectedId));

//when you just want to verify some detail about the values
mockEmailRequest.Verify(r=>r.EmailRecevied(It.Is<EmailResponse>(r=>r.Subject ==  "Something"),   It.Is<int>(i=>i > 17)));
4

1 回答 1

0

您应该使用以下代码:

mockEmailRequest.Verify(r=>r.EmailRecevied(It.Is<EmailResponse>(r=>r.Subject ==  "Something"), It.Is<int>(i=>i > 17)), Times.Exactly(5));
于 2013-03-07T08:45:36.177 回答