ASP.NET MVC - 准备使用 ControllerContext 模拟
我研究了几个示例,包括此处的一个,基本上是我需要知道的所有内容是这个领域是否有新的东西。
最棒的事情是拥有一些通过多个实际使用类/方法进行全面测试的现成可用的类/方法,这些类/方法将返回给我用于单元测试 ASP.NET MVC 控制器的 ControllerContext 的模拟。一个更理想的功能是不必担心要模拟什么,不要模拟什么 - 我只想要一个功能齐全的上下文。也许,我不需要它 90% 的功能,但这没关系。有那么甜的东西吗?
该解决方案可能会使用一些 Mock 框架,但这不是必需的 - 我只需要从黑匣子中得出结果。如果这个盒子实际上不是黑色的,那当然更好。
谢谢!
I studied several samples, including one here, and basically all I need to know is whether there is something new in the field.
The greatest thing would be having some ready-to-use thoroughly tested by multiple real-life uses class / method that will return me the mock of ControllerContext for unit testing ASP.NET MVC controllers. One more desirable feature is not having to worry about what to mock, what not to mock - I just want a fully functional context. Maybe, I will not need 90% of its functionality, but that's ok. Is there something that sweet?
The solution may use some Mock framework, but it is not necessary - I just need the result out from black box. If this box is not actually black, that's better, of course.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就我个人而言,我会推荐您MVCContrib TestHelper。它将使您的控制器单元测试非常优雅,并且您不必担心模拟上下文。
Personally I would recommend you MVCContrib TestHelper. It will make your controller unit tests very elegant and you shouldn't worry about mocking the context.