Unit testing razor views
"The Razor parser and view engine can be instantiated and used outside of the ASP.NET application domain. This means you can directly instantiate and use it within a unit test project without any de开发者_如何学编程pendencies on running ASP.NET"
Any ideas how can I do it ??
What I did was to create a unit test project and then added the mvc project into the reference. Then I instantited the controller object and invoke its action method.
You should be able to do assertion to check the contents of the view.
I think the easiest way to do is to create a new dummy mvc 3 project with a unit test project come with it. It will create an example Test Method for you.
Hope this helps.
精彩评论