Assert.IsNotNull(result);
}
2、测试RedirectToAction:
Code
public ActionResult TestRedirectToAction()
{
return RedirectToAction("Index");
}
//测试代码
[TestMethod]
public void TestRedirectToAction()
{
// Arrange
HomeController controller = new HomeController();
// Act
var result = controller.TestRedirectToAction() as RedirectToRouteResult; ;
// Assert
Assert.IsNotNull(result);
Assert.AreEqual("Index", result.RouteValues["action"]);
}
三、测试View Helpers
我们常常会把一些牵扯到逻辑的View代码写到Helper中,所以测试Helper非常有意义,我们先写一个简单的Helper
文章来源于领测软件测试网 https://www.ltesting.net/