mercredi 25 mars 2015

ViewData.Model is always null on Unit Test

on my controller



public ViewResult HelloWorld()
{
List<Sample> testData = new List<Sample>();
return View(testData);
}


on my unit test



[TestMethod]
public void TestMethod1()
{
var controller = new AdminController();
var result = (ViewResult)controller.HelloWorld();
List<Sample> testData = (List<Sample>)result.ViewData.Model;
}


when debugging, I always see there is something on testData on the quickwatch. but is always ends up as null when not on the quickwatch.


Aucun commentaire:

Enregistrer un commentaire