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