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"]); }
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; }
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; }