How to unit test asp.net mvc 2.0 controllers the right way!
I want to test that when my form data is posted back to my controllers that the data annotations and the model binding is going to do its job and give the correct model state. After 开发者_JAVA技巧googling for a while I can’t find a really good tutorial or article that shows how to do this.
Can anyone point me in the right direction?
What is the best practice in this area?
I have read that I may need to use moq and MVCContrib but I have not read a tutorial that makes me shout, “Yes, this is the right way to do it!”
This article made me shout "this is the right way". It shows usage of MVCContrib as an option. You can also use Moq or any other mocking engine to mock your controller dependencies, but generally there's no difference to unit testing any other, non-controller class.
精彩评论