Help testing mvc3 controller that accesses queryst

2019-08-23 04:22发布

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条回答
唯我独甜
2楼-- · 2019-08-23 05:00

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

查看更多
登录 后发表回答