开发者

MvcContrib Controller Test Returning Weird Results

开发者 https://www.devze.com 2023-01-11 08:21 出处:网络
I have a simple controller test using MvcContrib\'s test helpers: var controller = new HomeController();

I have a simple controller test using MvcContrib's test helpers:

var controller = new HomeController();
var result = controller.Contact();
result.AssertViewRendered().ForView("Contact").WithViewData<ContactViewModel>();

The only problem is, the controller method currently only returns a view, it is NOT setting a vie开发者_如何学编程w model yet. Why would this test return true???


This assert only verifies if the view is binded to the correct Model Type. It does not verifies if the Model is instaciated or populated.

You need another assert to verify if the model is created or has the correct data.

0

精彩评论

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