Beispiel #1
0
        public void IsMovieAvailableReturnsOneDvdItemNeverRented()
        {
            //arrange
            const int testMovieId         = 6;
            var       actualDvdItems      = CreateDvdListForIsMovieAvailable();
            var       actualRentalList    = CreateRentalListForIsMovieAvailable();
            var       actualMovieList     = new List <Movie>();
            var       expectedDvdItemList = new List <DvdItem>();

            expectedDvdItemList.Add(new DvdItem {
                dvdItemId = 7, movieId = 6, media = null, serial = "7", price = 1500
            });
            var MovieRepository   = new Mock <IMovieRepository>();
            var DvdItemRepository = new Mock <IDvdItemRepository>();
            var RentalRepository  = new Mock <IRentalRepository>();

            MovieRepository.Setup(o => o.Find()).Returns(actualMovieList);
            DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItems);
            RentalRepository.Setup(o => o.Find()).Returns(actualRentalList);

            var movieEngine = new RentalsEngine(MovieRepository.Object, DvdItemRepository.Object, RentalRepository.Object);

            //act
            var returnedIsMovieAvailableDvdItems = movieEngine.IsMovieAvailable(testMovieId);

            //assert
            Assert.IsNotNull(returnedIsMovieAvailableDvdItems, "Returned DvdItemList is null");
            Assert.AreEqual(1, returnedIsMovieAvailableDvdItems.Count);
            CollectionAssert.AreEquivalent(expectedDvdItemList, returnedIsMovieAvailableDvdItems, "Returned DvdItem List does not match expected");
        }
Beispiel #2
0
        public void IsMovieAvailableReturnsDvdItemNoneAvailable()
        {
            //arrange
            const int testMovieId      = 100;
            var       actualDvdItems   = CreateDvdList();
            var       actualRentalList = CreateRentalList();
            var       actualMovieList  = CreateMovieList();

            var expectedDvdItemList = new List <DvdItem>();

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

            MovieRepository.Setup(o => o.Find()).Returns(actualMovieList);
            DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItems);
            RentalRepository.Setup(o => o.Find()).Returns(actualRentalList);

            var movieEngine = new RentalsEngine(MovieRepository.Object, DvdItemRepository.Object, RentalRepository.Object);

            //act
            var returnedIsMovieAvailableDvdItems = movieEngine.IsMovieAvailable(testMovieId);

            //assert
            Assert.IsNotNull(returnedIsMovieAvailableDvdItems, "Returned DvdItemList is null");
            Assert.AreEqual(0, returnedIsMovieAvailableDvdItems.Count);
            CollectionAssert.AreEqual(expectedDvdItemList, returnedIsMovieAvailableDvdItems, "Returned DvdItem is not true");
        }
        public void IsMovieAvailableReturnsTwoDvdItemThreeAvailableOneRented()
        {
            //arrange
            const int testMovieId = 2;
            var actualDvdItems = CreateDvdListForIsMovieAvailable();
            var actualRentalList = CreateRentalListForIsMovieAvailable();
            var actualMovieList = new List<Movie>();
            var expectedDvdItemList = new List<DvdItem>();
            expectedDvdItemList.Add(new DvdItem { dvdItemId = 2, movieId = 2, media = null, serial = "2", price = 1500 });
            expectedDvdItemList.Add(new DvdItem { dvdItemId = 4, movieId = 2, media = null, serial = "4", price = 1500 });
            var MovieRepository = new Mock<IMovieRepository>();
            var DvdItemRepository = new Mock<IDvdItemRepository>();
            var RentalRepository = new Mock<IRentalRepository>();

            MovieRepository.Setup(o => o.Find()).Returns(actualMovieList);
            DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItems);
            RentalRepository.Setup(o => o.Find()).Returns(actualRentalList);

            var movieEngine = new RentalsEngine(MovieRepository.Object, DvdItemRepository.Object, RentalRepository.Object);

            //act
            var returnedIsMovieAvailableDvdItems = movieEngine.IsMovieAvailable(testMovieId);

            //assert
            Assert.IsNotNull(returnedIsMovieAvailableDvdItems, "Returned DvdItemList is null");
            Assert.AreEqual(2, returnedIsMovieAvailableDvdItems.Count);
            CollectionAssert.AreEquivalent(expectedDvdItemList, returnedIsMovieAvailableDvdItems, "Returned DvdItem List does not match expected");
        }
        public void IsMovieAvailableReturnsDvdItemNoneAvailable()
        {
            //arrange
            const int testMovieId = 100;
            var actualDvdItems = CreateDvdList();
            var actualRentalList = CreateRentalList();
            var actualMovieList = CreateMovieList();

            var expectedDvdItemList = new List<DvdItem>();

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

            MovieRepository.Setup(o => o.Find()).Returns(actualMovieList);
            DvdItemRepository.Setup(o => o.Find()).Returns(actualDvdItems);
            RentalRepository.Setup(o => o.Find()).Returns(actualRentalList);

            var movieEngine = new RentalsEngine(MovieRepository.Object, DvdItemRepository.Object, RentalRepository.Object);

            //act
            var returnedIsMovieAvailableDvdItems = movieEngine.IsMovieAvailable(testMovieId);

            //assert
            Assert.IsNotNull(returnedIsMovieAvailableDvdItems, "Returned DvdItemList is null");
            Assert.AreEqual(0, returnedIsMovieAvailableDvdItems.Count);
            CollectionAssert.AreEqual(expectedDvdItemList, returnedIsMovieAvailableDvdItems, "Returned DvdItem is not true");
        }