public Details ( int id ) : System.Web.Mvc.ActionResult | ||
id | int | |
Результат | System.Web.Mvc.ActionResult |
public void Details_Action_Get_Correct_Details() { Mock<IUnitOfWork> mock = new Mock<IUnitOfWork>(); mock.Setup(s => s.StudentRepo.GetById(It.IsAny<int>())).Returns(student4); StudentController controller = new StudentController(mock.Object); ViewResult vr = controller.Details(4) as ViewResult; Student result = (Student)vr.Model; Assert.AreEqual(result.FirstMidName, "Adam"); Assert.AreEqual(result.LastName, "Freeman"); }
public void Details_Thorw_HttpNotFound() { Mock<IUnitOfWork> mock = new Mock<IUnitOfWork>(); Student student = null; mock.Setup(s => s.StudentRepo.GetById(It.IsAny<int>())).Returns(student); StudentController controller = new StudentController(mock.Object); var result = controller.Details(0) as HttpNotFoundResult; Assert.IsNotNull(result); Assert.AreEqual(result.StatusCode, 404); }