コード例 #1
0
        public void ConfirmedUpdateTestExceptionThrown()
        {
            var rentalDal = new MockRentalDal()
            {
                ThrowError = true
            };
            var controller = new OrdersController(rentalDal);
            var result     = (ViewResult)controller.ConfirmedUpdate(new RentalItem());

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreEqual("UpdateStatus", result.ViewName);
            Assert.AreEqual("Uh-oh something went wrong", result.ViewData["ErrorMessage"]);
        }
コード例 #2
0
        public void ConfirmedUpdateTestValid()
        {
            var rentalDal = new MockRentalDal()
            {
                ThrowError = false
            };
            var controller = new OrdersController(rentalDal);

            HomeController.CurrentEmployee = new Employee();
            var result = (RedirectToActionResult)controller.ConfirmedUpdate(new RentalItem {
                RentalId = 1, Status = "Ordered"
            });

            Assert.IsInstanceOfType(result, typeof(RedirectToActionResult));
            Assert.AreEqual("EmployeeLanding", result.ActionName);
            HomeController.CurrentEmployee = null;
        }
コード例 #3
0
        public void ConfirmedUpdateTestInvalid()
        {
            var rentalDal = new MockRentalDal()
            {
                ThrowError = false
            };
            var controller = new OrdersController(rentalDal);

            controller.ModelState.AddModelError("test", "test");
            HomeController.CurrentEmployee = new Employee();
            var result = (ViewResult)controller.ConfirmedUpdate(new RentalItem {
                RentalId = 1, Status = "Returned"
            });

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreEqual("UpdateStatus", result.ViewName);
            HomeController.CurrentEmployee = null;
        }