I have the following action:
public ViewResult Index() { var model = new MyIndexViewModel { TotalTips = (decimal)7.51 }; return View(model); } I would like to write a unit test that verifies that model.TotalTips is 7.51.
I am trying something like this:
[TestMethod] public void Test() { // Arrange var controller = new MyController(_mockRepository.Object); MyIndexViewModel test = new MyIndexViewModel{TotalTips = (decimal)7.51}; // Action ViewResult result = controller.Index(); // Assert Assert.AreEqual(result.ViewData.Model.TotalTips, test.TotalTips); // Problem line } But I cannot resolve TotalTips on result.ViewData.Model.TotalTips.
I know this is wrong, but cannot figure out how to properly resolve the model I am posting to the Index view.