使用 Moq 如何验证函数是否在不指定参数的情况下被调用?
有时我只想验证函数是否被调用,而不是测试使用特定参数调用函数。
原因是有一个复杂的对象作为参数传入,但该函数内部的后续调用会进行数据库获取。由于这将被嘲笑,因此它只会有 null 和0秒。
我只想验证调用而不测试传入的参数。我该怎么做?
Sometimes I want to just verify that a function was called rather than have to test the function was called with specific parameters.
The reason for this that there is a complex object being passed in as a parameter, but the later call inside that function makes a database fetch. Since this will be mocked, it will just have nulls & 0s.
I just want to verify the call without testing against the passed in parameters. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会发现以下博客文章很有用。引用:
You may find the following blog post useful. Quote: