Exemple #1
0
        public void GetAllByGenre_Should_GetThemCorrect()
        {
            var db = new TFContext(DatabaseSimulator());
            var genreServiceMock = new Mock <IGenreServices>();
            var movieServices    = new MovieServices(db, genreServiceMock.Object);

            var movie = new Movie()
            {
                Id = 1
            };
            var secondMovie = new Movie()
            {
                Id = 2
            };
            var deletedMovie = new Movie()
            {
                Id        = 3,
                IsDeleted = true
            };
            var differentGenreMovie = new Movie()
            {
                Id = 4
            };
            var movieGenre = new MoviesGenres()
            {
                MovieId = 1,
                GenreId = 1
            };
            var secondMovieGenre = new MoviesGenres()
            {
                MovieId = 2,
                GenreId = 1
            };
            var thirdMovieGenre = new MoviesGenres()
            {
                MovieId = 3,
                GenreId = 1
            };
            var differentMovieGenre = new MoviesGenres()
            {
                MovieId = 4,
                GenreId = 2
            };

            db.Movies.AddRange(movie, secondMovie, deletedMovie, differentGenreMovie);
            db.MoviesGenres.AddRange(movieGenre, secondMovieGenre, thirdMovieGenre, differentMovieGenre);
            db.SaveChanges();

            Assert.AreEqual(2, movieServices.GetAllByGenre(1).Count());
        }