Example #1
0
        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);
        }
Example #2
0
        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"]);
        }
Example #3
0
        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"]);
        }
Example #4
0
        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"]);
        }