帮助测试访问查询字符串的 mvc3 控制器
刚开始学习mvc3。我已经构建了一个相当基本的网站(如果有影响的话也使用 EF-Code-First),现在我正在尝试为其构建测试
我的控制器通过 Request["whatever" 获取查询字符串数据]
,当我运行测试时,它说 request is null
到目前为止我看过的所有教程都有点迷失了。进入模拟等,他们似乎假设事先了解这些知识(从未使用过模拟,所以还不理解它们)
是否有人有一个很好的基本教程来让我进入单元测试?或者也许可以给我一个例子
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
直接使用HttpRequest是违反MVC的设计模式的。您可以将操作中的查询字符串变量作为参数进行访问。
It is against MVC's design pattern to use HttpRequest directly. You can access the query string variables on your action as parameters.