Help testing mvc3 controller that accesses querystring

大城市里の小女人 提交于 2019-12-12 06:31:17

问题


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


回答1:


It is against MVC's design pattern to use HttpRequest directly. You can access the query string variables on your action as parameters.



来源:https://stackoverflow.com/questions/5751490/help-testing-mvc3-controller-that-accesses-querystring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!