public void Edit_Valid()
        {
            //Arrange
            Type model = new Type()
            {
                Description = "test",
                Status      = "test"
            };

            //Act
            var result = (RedirectToRouteResult)controllerWEB.Edit(new TypeViewModel
            {
                ID          = model.ID,
                Description = model.Description,
                Status      = model.Status
            });

            //Assert
            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
Esempio n. 2
0
        public void Type_Edit()
        {
            // Arrange
            TypeController    controller = new TypeController();
            ListItemEditModel newItem    = GetDemo(TestId);
            var saveresult = controller.Edit(newItem) as ViewResult;

            if (saveresult != null)
            {
                var savedItem = (ListItemEditModel)saveresult.ViewData.Model;
                Assert.AreEqual(true, saveresult.ViewData.ModelState.IsValid, "ModelState");
                Assert.AreEqual("UT_LIN", savedItem.EditItem.ListItemName);
            }

            var result = controller.Edit(TestId.ToString(), false) as ViewResult;
            ListItemEditModel editItem = (ListItemEditModel)result.ViewData.Model;

            Assert.IsNotNull(result);
            Assert.AreEqual(TestId, editItem.EditItem.Id);
            Assert.AreEqual("UT_LIN", editItem.EditItem.ListItemName);
            Assert.AreEqual("Unit Test List Item Description (amended)", editItem.EditItem.ListItemDescr);
        }
Esempio n. 3
0
        public void Type_Edit_Redirect()
        {
            // Arrange
            TypeController    controller = new TypeController();
            ListItemEditModel item       = GetDemo(0);

            var result = controller.Edit(item) as RedirectToRouteResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("Edit", result.RouteValues["action"]);
            Assert.AreEqual(true, result.RouteValues["success"]);
            Assert.AreNotEqual(0, result.RouteValues["id"]);

            TestId = (int)result.RouteValues["id"];
        }