public void CheckoutMovieNotAlreadyRented() { //arrange const int testClientId = 1; const int testDvdItemId = 1; var actualRentalList = CreateRentalList(); var actualDvdItemList = CreateDvdItemList(); var expectedRental = new Rental { rentalId = 11, dvdItemId = testDvdItemId, clientId = testClientId, rentalDate = new DateTime(2015, 09, 16, 14, 00, 00), expectedReturnDate = new DateTime(2015, 09, 17, 11, 00, 00) }; var actualRentalReturned = new Rental(); var RentalRepository = new Mock <IRentalRepository>(); var DvdItemRepository = new Mock <IDvdItemRepository>(); RentalRepository.Setup(o => o.Find()).Returns(actualRentalList); DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItemList); var movieEngine = new RentalsEngine(null, DvdItemRepository.Object, RentalRepository.Object); //act var returnedRentalCheckout = movieEngine.CheckoutRental(testClientId, testDvdItemId); //assert Assert.IsNotNull(returnedRentalCheckout, "Returned Checkout is null"); Assert.IsTrue(returnedRentalCheckout, "Returned Checkout is not false"); RentalRepository.Verify(x => x.Add(It.Is <Rental>(r => r.clientId == 1 && r.dvdItemId == 1))); }
public void CheckoutMovieAlreadyRented() { //arrange const int testClientId = 3; const int testDvdItemId = 23; var actualRentalList = CreateRentalList(); var actualDvdItemList = CreateDvdItemList(); var RentalRepository = new Mock<IRentalRepository>(); var DvdItemRepository = new Mock<IDvdItemRepository>(); RentalRepository.Setup(o => o.Find()).Returns(actualRentalList); DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItemList); var movieEngine = new RentalsEngine(null, DvdItemRepository.Object, RentalRepository.Object); //act var returnedRentalCheckout = movieEngine.CheckoutRental(testClientId, testDvdItemId); //assert Assert.IsNotNull(returnedRentalCheckout, "Returned Checkout is null"); Assert.IsFalse(returnedRentalCheckout, "Returned Checkout is not false"); }
public void CheckoutMovieAlreadyRented() { //arrange const int testClientId = 3; const int testDvdItemId = 23; var actualRentalList = CreateRentalList(); var actualDvdItemList = CreateDvdItemList(); var RentalRepository = new Mock <IRentalRepository>(); var DvdItemRepository = new Mock <IDvdItemRepository>(); RentalRepository.Setup(o => o.Find()).Returns(actualRentalList); DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItemList); var movieEngine = new RentalsEngine(null, DvdItemRepository.Object, RentalRepository.Object); //act var returnedRentalCheckout = movieEngine.CheckoutRental(testClientId, testDvdItemId); //assert Assert.IsNotNull(returnedRentalCheckout, "Returned Checkout is null"); Assert.IsFalse(returnedRentalCheckout, "Returned Checkout is not false"); }
public void CheckoutMovieNotAlreadyRented() { //arrange const int testClientId = 1; const int testDvdItemId = 1; var actualRentalList = CreateRentalList(); var actualDvdItemList = CreateDvdItemList(); var expectedRental = new Rental { rentalId = 11, dvdItemId = testDvdItemId, clientId = testClientId, rentalDate = new DateTime(2015, 09, 16, 14, 00, 00), expectedReturnDate = new DateTime(2015, 09, 17, 11, 00, 00) }; var actualRentalReturned = new Rental(); var RentalRepository = new Mock<IRentalRepository>(); var DvdItemRepository = new Mock<IDvdItemRepository>(); RentalRepository.Setup(o => o.Find()).Returns(actualRentalList); DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItemList); var movieEngine = new RentalsEngine(null, DvdItemRepository.Object, RentalRepository.Object); //act var returnedRentalCheckout = movieEngine.CheckoutRental(testClientId, testDvdItemId); //assert Assert.IsNotNull(returnedRentalCheckout, "Returned Checkout is null"); Assert.IsTrue(returnedRentalCheckout, "Returned Checkout is not false"); RentalRepository.Verify(x => x.Add(It.Is<Rental>(r => r.clientId ==1 && r.dvdItemId == 1))); }