views:

15

answers:

1

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 view model yet. Why would this test return true???

A: 

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.

Sir Gallahad