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 LibrariansChoiceValid() { var mockMediaDal = new MockMediaDal { ThrowError = false }; var controller = new BorrowController(new MockBorrowDal(), mockMediaDal, new MockMemberDal()); var result = (ViewResult)controller.LibrariansChoice(); Assert.AreEqual("Browse", result.ViewName); }
public void LibrariansChoiceWithException() { var mockMediaDal = new MockMediaDal { ThrowError = true }; var controller = new BorrowController(new MockBorrowDal(), mockMediaDal, new MockMemberDal()); var result = (ViewResult)controller.LibrariansChoice(); Assert.AreEqual("Browse", result.ViewName); Assert.AreEqual("Uh-oh.. something went wrong", result.ViewData["Error"]); }
public void TypeFilterTestWithExceptionThrown() { var mediaDal = new MockMediaDal { ThrowError = true }; var controller = new BorrowController(new MockBorrowDal(), mediaDal, new MockMemberDal()); var result = (ViewResult)controller.TypeFilter("Action"); Assert.AreEqual("Browse", result.ViewName); Assert.AreEqual("Uh-oh something went wrong", result.ViewData["Error"]); }
public void BrowseTest() { var mediaDal = new MockMediaDal { ThrowError = false }; var controller = new BorrowController(new MockBorrowDal(), mediaDal, new MockMemberDal()); var result = (ViewResult)controller.Browse(); Assert.AreEqual("Browse", result.ViewName); var actualList = (List <Media>)result.Model; Assert.AreEqual(1, actualList.Count); }
public void CategoryFilterTestWithoutAll() { var mediaDal = new MockMediaDal { ThrowError = false }; var controller = new BorrowController(new MockBorrowDal(), mediaDal, new MockMemberDal()); var result = (ViewResult)controller.CategoryFilter("Action"); Assert.AreEqual("Browse", result.ViewName); var actualList = (List <Media>)result.Model; Assert.AreEqual(1, actualList.Count); }
public void ConfirmedBorrowTestWithValidInput() { var mockBorrowDal = new MockBorrowDal { ThrowException = false, ThrowNullReference = false }; var mockMediaDal = new MockMediaDal(); var borrowItem = new ConfirmBorrowObject(); var controller = new BorrowController(mockBorrowDal, mockMediaDal, new MockMemberDal()); var result = (RedirectToActionResult)controller.ConfirmedBorrow(borrowItem); Assert.IsInstanceOfType(result, typeof(RedirectToActionResult)); Assert.AreEqual("Browse", result.ActionName); }
public void BrowseTestWithException() { var mediaDal = new MockMediaDal { ThrowError = true }; var controller = new BorrowController(new MockBorrowDal(), mediaDal, new MockMemberDal()); var result = (ViewResult)controller.Browse(); Assert.AreEqual(null, result.ViewName); Assert.AreEqual("Uh-oh.. something went wrong", result.ViewData["Error"]); var actualList = (List <Media>)result.Model; Assert.AreEqual(0, actualList.Count); }
public void ConfirmedBorrowTestWithException() { var mockBorrowDal = new MockBorrowDal { ThrowException = true, ThrowNullReference = false }; var mockMediaDal = new MockMediaDal(); var borrowItem = new ConfirmBorrowObject(); var controller = new BorrowController(mockBorrowDal, mockMediaDal, new MockMemberDal()); var result = (ViewResult)controller.ConfirmedBorrow(borrowItem); Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.AreEqual("ConfirmBorrow", result.ViewName); Assert.AreEqual("Exception of type 'System.Exception' was thrown.", result.ViewData["Error"]); }
public void ConfirmedBorrowTestWithNullReference() { var mockBorrowDal = new MockBorrowDal { ThrowException = false, ThrowNullReference = true }; var mockMediaDal = new MockMediaDal(); var borrowItem = new ConfirmBorrowObject(); var controller = new BorrowController(mockBorrowDal, mockMediaDal, new MockMemberDal()); var result = (ViewResult)controller.ConfirmedBorrow(borrowItem); Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.AreEqual("ConfirmBorrow", result.ViewName); Assert.AreEqual("Please log in again.", result.ViewData["Error"]); Assert.AreEqual("Object reference not set to an instance of an object.", result.ViewData["ErrorMessage"]); }
public void ConfirmedBorrowTestWithInvalidInput() { var mockBorrowDal = new MockBorrowDal { ThrowException = false, ThrowNullReference = false }; var mockMediaDal = new MockMediaDal(); var borrowItem = new ConfirmBorrowObject(); var controller = new BorrowController(mockBorrowDal, mockMediaDal, new MockMemberDal()); controller.ModelState.AddModelError("Error", "Error"); var result = (ViewResult)controller.ConfirmedBorrow(borrowItem); Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.AreEqual("ConfirmBorrow", result.ViewName); Assert.AreEqual("Please select a shipping address", result.ViewData["Error"]); }
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); }