Beispiel #1
0
        public void CreateGet_Model_IsEditingModelObject_moq()
        {
            var mock       = new Mock <IList <Patcient> >();
            var controller = new PatcientCrudController()
            {
                Objects = mock.Object
            };

            ViewResult result = controller.Create() as ViewResult;

            Assert.IsInstanceOfType(result.Model, typeof(PatcientEditingModel));
        }
Beispiel #2
0
        public void CreatePost_TempData_KeysContains_message_moq()
        {
            var mock       = new Mock <IList <Patcient> >();
            var controller = new PatcientCrudController()
            {
                Objects = mock.Object
            };
            var model = new PatcientEditingModel();


            ActionResult result = controller.Create(model);

            Assert.IsFalse(controller.TempData.Keys.Contains("massage"));
        }
Beispiel #3
0
        ////
        public void CreatePost_Result_RedirectToActionIndex_moq()
        {
            var mock       = new Mock <IList <Patcient> >();
            var controller = new PatcientCrudController()
            {
                Objects = mock.Object
            };
            var model = new PatcientEditingModel();


            ActionResult result = controller.Create(model);

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            var redirectResult = result as RedirectToRouteResult;

            Assert.AreEqual(redirectResult.RouteValues["action"], "Index");
        }
Beispiel #4
0
        public void CreatePost_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.Create(model);

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            var viewResult = result as ViewResult;

            Assert.AreEqual(viewResult.Model, model);
        }