帮助测试访问querystring的mvc3控制器 [英] Help testing mvc3 controller that accesses querystring
问题描述
我的控制器通过去请求[any]
获取查询字符串数据,当我运行测试时,表示请求为null
我所看过的所有教程到目前为止,都让我失望了。进入嘲弄等等,他们似乎假定先前的知识(从来没有使用嘲笑,所以还不明白他们)
有没有人有一个很好的基本教程让我进行单元测试?或者可能给我一个例子
这是反对MVC的设计模式直接使用HttpRequest。您可以访问作为参数的操作的查询字符串变量。
Just started learning mvc3. I've built a fairly basic website (also using EF-Code-First if that makes a difference), now I'm trying to progress to building tests for it
My controller gets querystring data by going Request["whatever"]
, and when I run the test it says request is null
All the tutorials I've looked at so far have kinda lost me. Going into mocks and such, which they seem to assume prior knowledge of (never used mocks, so don't understand them yet)
Does anyone have a nice and basic tutorial to get me into unit testing? Or perhaps could give me an example
It is against MVC's design pattern to use HttpRequest directly. You can access the query string variables on your action as parameters.
这篇关于帮助测试访问querystring的mvc3控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!