VerificationException单元测试过程中实例化MVC控制器时, [英] VerificationException when instantiating MVC controller during unit testing

查看:138
本文介绍了VerificationException单元测试过程中实例化MVC控制器时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做与一些单元测试微软正版正货框架,和一切工作正常,直到我加入 System.Web.Mvc 假装配。从那一刻起任何时候我尝试在一个单元测试来初始化控制器, VerificationException 被抛出。当我删除的假集引用一切工作正常。不过,我需要这种假以垫片的 A UrlHelper 对象的操作方法。

I am doing some unit testing with Microsoft Fakes Framework, and everything works fine until I add System.Web.Mvc fake assembly. From that moment any time I try to initialize a controller in a unit test, a VerificationException is thrown. When I remove the Fake assembly reference everything works fine. However, I need this fake in order to shim an Action method of a UrlHelper object.

我已经看到了一些链接,在这里就这样,但他们大多是关于 FluentValidation 这是没有帮助我。此外,通过的丰富Czyzewski ,<一个极好的文章href=\"http://www.richonsoftware.com/post/2012/05/02/Noninvasive-Unit-Testing-in-ASPNET-MVC-A-Microsoft-Fakes-Deep-Dive.aspx\"相对=nofollow>无创单元测试ASP.NET MVC4 - 微软正版正货深潜,没有帮助,因为我完全不知道他是如何实例化 UrlHelper 。我遵循同样的例子,他表示,但 UrlHelper 构造函数抛出 VerificationException 以及

I've seen some link's here on SO, but they are mostly about FluentValidation which is of no help to me. Also, an excellent article by Rich Czyzewski, Noninvasive Unit Testing in ASP.NET MVC4 – A Microsoft Fakes Deep Dive, did not help as I have absolutely no idea how he managed to instantiate UrlHelper. I followed the same example that he shows, but UrlHelper constructor throws VerificationException as well.

除了含有丰富的存根我还添加了的Htt presponseBase HttpSessionBase 等创建类似的情况,可以在斯科特Hanselman的的博客, ASP.NET中找到MVC会议在MIX08上,TDD和MvcMockHelpers 的,但仍没有运气。

In addition to Rich's stubs I also added HttpResponseBase, HttpSessionBase, etc. to create a similar scenario that can be found on Scott Hanselman's blog, ASP.NET MVC Session at Mix08, TDD and MvcMockHelpers, but still no luck.

有没有人设法解决这个问题,以及如何?

Has anyone managed to get around this problem and how?

在此先感谢大家!

推荐答案

这是在与Visual Studio 2012 RTM版本运假货版本的限制。我们在即将到来的季报2固定它的CTP将是可供下载在几个星期。

This is a limitation in the version of Fakes that shipped with Visual Studio 2012 RTM release. We have fixed it in the upcoming Quarterly Update 2, the CTP will be available for download in a few weeks.

这篇关于VerificationException单元测试过程中实例化MVC控制器时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆