开发者

Unit testing razor views

开发者 https://www.devze.com 2023-03-30 14:37 出处:网络
\"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开

"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.

0

精彩评论

暂无评论...
验证码 换一张
取 消