예제 #1
0
        public void ReturnRentalReturnsFalseReturnNeverRented()
        {
            //arrange
            const string testSerial         = "45636";
            var          actualRentalList   = CreateRentalList();
            var          actualDvdItemsList = CreateDvdList();

            var RentalRepository  = new Mock <IRentalRepository>();
            var DvdItemRepository = new Mock <IDvdItemRepository>();

            RentalRepository.Setup(o => o.Find()).Returns(actualRentalList);
            DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItemsList);
            var movieEngine = new RentalsEngine(null, DvdItemRepository.Object, RentalRepository.Object);

            //act
            var ReturnRentalResponse = movieEngine.ReturnRental(testSerial);

            //assert
            Assert.IsNotNull(ReturnRentalResponse, "Returned ReturnedRental is null");
            Assert.IsFalse(ReturnRentalResponse, "Returned ReturnedRental is not False");
        }
예제 #2
0
        public void ReturnRentalReturnsTrue()
        {
            //arrange
            const string testSerial         = "64356";
            var          actualRentalList   = CreateRentalList();
            var          actualDvdItemsList = CreateDvdList();

            var RentalRepository  = new Mock <IRentalRepository>();
            var DvdItemRepository = new Mock <IDvdItemRepository>();

            RentalRepository.Setup(o => o.Find()).Returns(actualRentalList);
            DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItemsList);
            var movieEngine = new RentalsEngine(null, DvdItemRepository.Object, RentalRepository.Object);

            //act
            var ReturnRentalResponse = movieEngine.ReturnRental(testSerial);

            //assert
            Assert.IsNotNull(ReturnRentalResponse, "Returned ReturnedRental is null");
            Assert.IsTrue(ReturnRentalResponse, "Returned ReturnedRental is not True");
            RentalRepository.Verify(x => x.Modify(It.Is <Rental>(r => r.clientId == 5)));
        }
예제 #3
0
        public void ReturnRentalReturnsTrue()
        {
            //arrange
            const string testSerial = "64356";
            var actualRentalList = CreateRentalList();
            var actualDvdItemsList = CreateDvdList();

            var RentalRepository = new Mock<IRentalRepository>();
            var DvdItemRepository = new Mock<IDvdItemRepository>();
            RentalRepository.Setup(o => o.Find()).Returns(actualRentalList);
            DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItemsList);
            var movieEngine = new RentalsEngine(null, DvdItemRepository.Object, RentalRepository.Object);

            //act
            var ReturnRentalResponse = movieEngine.ReturnRental(testSerial);

            //assert
            Assert.IsNotNull(ReturnRentalResponse, "Returned ReturnedRental is null");
            Assert.IsTrue(ReturnRentalResponse, "Returned ReturnedRental is not True");
            RentalRepository.Verify(x => x.Modify(It.Is<Rental>(r => r.clientId == 5)));
        }
예제 #4
0
        public void ReturnRentalReturnsFalseReturnNotRented()
        {
            //arrange
            const string testSerial = "72376";
            var actualRentalList = CreateRentalList();
            var actualDvdItemsList = CreateDvdList();

            var RentalRepository = new Mock<IRentalRepository>();
            var DvdItemRepository = new Mock<IDvdItemRepository>();
            RentalRepository.Setup(o => o.Find()).Returns(actualRentalList);
            DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItemsList);
            var movieEngine = new RentalsEngine(null, DvdItemRepository.Object, RentalRepository.Object);

            //act
            var ReturnRentalResponse = movieEngine.ReturnRental(testSerial);

            //assert
            Assert.IsNotNull(ReturnRentalResponse, "Returned ReturnedRental is null");
            Assert.IsFalse(ReturnRentalResponse, "Returned ReturnedRental is not False");
        }