in my unit test, the ViewResult.ViewName property is always empty when i use the action name for the view:
return View(model);
or
return View();
Is that by design?
Yes it is by design:
protected internal ViewResult View()
{
return this.View(null, null, null);
}
Checkout MVCContrib.TestHelper for better syntax:
// act
var actual = controller.Index();
// assert
actual.AssertViewRendered();
Looks like it is indeed:
protected internal ViewResult View()
{
return this.View(null, null, null);
}
protected internal virtual ViewResult View(string viewName,
string masterName, object model)
{
if (model != null)
{
base.ViewData.Model = model;
}
ViewResult result = new ViewResult();
result.ViewName = viewName;
result.MasterName = masterName;
result.ViewData = base.ViewData;
result.TempData = base.TempData;
return result;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With