Reputation: 6789
"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 dependencies on running ASP.NET"
Any ideas how can I do it ??
Upvotes: 10
Views: 3711
Reputation: 536
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.
Upvotes: 2