MvcContrib Controller Test Returning Weird Results
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.
精彩评论