public void ConfirmBorrowTestWithException() { var mediaDal = new MockMediaDal { ThrowError = true }; var controller = new BorrowController(new MockBorrowDal(), mediaDal, new MockMemberDal()); var result = (RedirectToActionResult)controller.ConfirmBorrow(1); Assert.AreEqual("Browse", result.ActionName); }
public void ConfirmBorrowTestWithMoreThanAllowedRentals() { var mediaDal = new MockMediaDal { ThrowError = false }; var mockBorrowDal = new MockBorrowDal { ThrowException = false, ThrowNullReference = false, NumberToReturn = 3 }; HomeController.CurrentUser = new Member(); var controller = new BorrowController(mockBorrowDal, mediaDal, new MockMemberDal()); var result = (ViewResult)controller.ConfirmBorrow(1); Assert.AreEqual("Browse", result.ViewName); Assert.AreEqual($"Looks like you have already rented 3 items. Please return something to rent another.", result.ViewData["Error"]); }
public void ConfirmBorrowTest() { var mediaDal = new MockMediaDal { ThrowError = false }; var mockBorrowDal = new MockBorrowDal { ThrowException = false, ThrowNullReference = false, NumberToReturn = 1 }; HomeController.CurrentUser = new Member(); var controller = new BorrowController(mockBorrowDal, mediaDal, new MockMemberDal()); var result = (ViewResult)controller.ConfirmBorrow(1); Assert.AreEqual(null, result.ViewName); var actualItem = (ConfirmBorrowObject)result.Model; Assert.AreEqual(1, BorrowController.SelectedItem.InventoryId); }