我被建议按照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)));
答案 0 :(得分:0)
您应该使用以下代码:
mockEmailRequest.Verify(r=>r.EmailRecevied(It.Is<EmailResponse>(r=>r.Subject == "Something"), It.Is<int>(i=>i > 17)), Times.Exactly(5));