public void EditGet_Model_IsEditingModelObject_moq() { var mock = new Mock <IList <Patcient> >(); var controller = new PatcientCrudController() { Objects = mock.Object }; var model = new PatcientEditingModel(); ViewResult result = controller.Edit(model) as ViewResult; //Assert.IsInstanceOfType(result.Model, typeof(PatcientEditingModel)); }
public void EditPost_TempData_KeysContains_message_moq() { var mock = new Mock <IList <Patcient> >(); var controller = new PatcientCrudController() { Objects = mock.Object }; var model = new PatcientEditingModel(); ActionResult result = controller.Edit(model); Assert.IsFalse(controller.TempData.Keys.Contains("massage")); }
//// public void EditPost_Result_RedirectToActionIndex_moq() { var mock = new Mock <IList <Patcient> >(); var controller = new PatcientCrudController() { Objects = mock.Object }; var model = new PatcientEditingModel(); ActionResult result = controller.Edit(model); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); var redirectResult = result as RedirectToRouteResult; Assert.AreEqual(redirectResult.RouteValues["action"], "Index"); }
public void EditPost_ModelStateIsNotValid_ReturnedViewResult_moq() { var mock = new Mock <IList <Patcient> >(); var controller = new PatcientCrudController() { Objects = mock.Object }; var model = new PatcientEditingModel(); controller.ModelState.AddModelError("", "error message"); ActionResult result = controller.Edit(model); Assert.IsInstanceOfType(result, typeof(ViewResult)); var viewResult = result as ViewResult; Assert.AreEqual(viewResult.Model, model); }