如何管理 Mock使用 MSTest 作为普通 IMediator 工作
我正在使用 Mock 通过测试方法在控制器中建立中介变量。 但是,当程序遇到引用模拟的中介变量时,测试用例会失败,并且也不会返回任何输出。
等待_mediator.Send(新的Repository_function_used)
调用存储库函数并初始化所有变量。但是当 mediator.Send() 函数工作时,处理程序不会注册来调用存储库类中的 Handle 方法。
最好的替代方案是什么?
Test 类有这一行用于调用控制器方法。
var result =等待controller.Method_Name_in_Controller();
I am using Mock to establish the mediator variable in the controller via the test method.
But when the program encounters the mediator variable referring to mock the test case fails and as well no output is returned.
await _mediator.Send(new Repository_function_called)
the repository function is called and all the variables are initialized. But when the mediator.Send() function is to work, the handler doesn't register to call the Handle method in the repository class.
What is the best possible alternative?
The Test class has this line for calling the controller method.
var result = await controller.Method_Name_in_Controller();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此方法不会产生最小起订量值,但会很有帮助!
This method would not make a Moq value, and would be helpful!