Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 dependencies on running ASP.NET"

Any ideas how can I do it ??

like image 712
Alim Ul Gias Avatar asked Aug 23 '11 04:08

Alim Ul Gias


1 Answers

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.

like image 106
frostshoxx Avatar answered Sep 27 '22 18:09

frostshoxx