Exemple #1
0
        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));
        }
Exemple #2
0
        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"));
        }
Exemple #3
0
        ////
        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");
        }
Exemple #4
0
        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);
        }