public void GetCountOfMovieReviewers_ValidArguments(int movie, int count)
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.Add(new MovieRatings(1, 3, 1, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 1, 4, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 2, 1, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 2, 1, DateTime.Now));
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            int actual = movieRatingService.getCountOfMovieReviewers(movie);

            Assert.Equal(count, actual);
        }
        public void GetAverageRateGivenByReviewer_ValidArguments_ReturnZero(int reviewer, double average)
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.Add(new MovieRatings(1, 1, 2, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 2, 4, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, 1, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 4, 1, DateTime.Now));
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            double actual = movieRatingService.getAverageRateGivenByReviewer(reviewer);

            Assert.Equal(average, actual);
        }
        public void GetNumberOfReviewsFromReviewer_ValidArguments(int reviewer, int reviews)
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.Add(new MovieRatings(1, 3, 2, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(1, 1, 2, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 2, 2, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, 2, DateTime.Now));
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            int actual = movieRatingService.getNumberOfReviewsFromReviewer(reviewer);

            Assert.Equal(reviews, actual);
        }
        public void InvalidGrade_ThrowsArgumentException(int movie, int grade)
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.Add(new MovieRatings(2, 2, 2, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, 3, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, 3, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, 3, DateTime.Now));
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            Action actual = () => movieRatingService.getCountOfGradesGottenByMovie(movie, grade);

            Assert.Throws <ArgumentException>(actual);
        }
        public void AverageRatingRecievedByMovie_ValidArguments_ReturnZero(int movie, double average)
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.Add(new MovieRatings(1, 1, 2, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 1, 4, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 2, 1, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 2, 1, DateTime.Now));
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            double actual = movieRatingService.averageRatingRecievedByMovie(movie);

            Assert.Equal(average, actual);
        }
        public void GetCountOfGradesGivenByReviewer_ValidArguments(int reviewer, int grade, int count)
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.Add(new MovieRatings(3, 3, grade, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(3, 4, grade, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 1, grade, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 2, grade, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, grade, DateTime.Now));
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            int actual = movieRatingService.getCountOfGradesGivenByReviewer(reviewer, grade);

            Assert.Equal(count, actual);
        }
        public void GetCountOfGradesGottenByMovie_ValidArgumentse(int movie, int grade, int count)
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.Add(new MovieRatings(2, 2, 4, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, 3, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, 3, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, 3, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, 3, DateTime.Now));
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            int actual = movieRatingService.getCountOfGradesGottenByMovie(movie, grade);

            Assert.Equal(count, actual);
        }
        public void GetAllReviewersFromMovie_ValidArguments()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();
            MovieRatings          movieRating1          = new MovieRatings(1, 1, 5, DateTime.Now.AddYears(4));
            MovieRatings          movieRating2          = new MovieRatings(2, 1, 5, DateTime.Now.AddYears(3));
            MovieRatings          movieRating3          = new MovieRatings(3, 1, 4, DateTime.Now.AddYears(3));
            MovieRatings          movieRating4          = new MovieRatings(4, 1, 3, DateTime.Now.AddYears(2));
            MovieRatings          movieRating5          = new MovieRatings(3, 2, 1, DateTime.Now);

            movieRatingRepository.Add(movieRating1);
            movieRatingRepository.Add(movieRating2);
            movieRatingRepository.Add(movieRating3);
            movieRatingRepository.Add(movieRating4);
            movieRatingRepository.Add(movieRating5);
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            List <MovieRatings> expected = new List <MovieRatings>()
            {
                movieRating1, movieRating2, movieRating3, movieRating4
            };
            List <MovieRatings> actual = movieRatingService.getAllReviewersFromMovie(1);

            Assert.Equal(expected, actual);
        }
        public void GetTopMoviesByAverageGrader_ValidArguments()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.Add(new MovieRatings(1, 7, 5, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(1, 6, 5, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(1, 6, 1, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(1, 6, 4, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(1, 5, 3, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 4, 2, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 3, 3, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(3, 2, 1, DateTime.Now));
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            List <int> expected = new List <int>()
            {
                7, 6, 5, 3, 4
            };
            List <int> actual = movieRatingService.getTopMoviesByAverageGrade(5);

            Assert.Equal(expected, actual);
        }
示例#10
0
        public void GetTopGradedMovies_ValidArguments()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.Add(new MovieRatings(1, 6, 5, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 6, 5, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(1, 4, 3, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(1, 5, 4, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(1, 3, 2, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(1, 2, 1, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(2, 2, 1, DateTime.Now));
            movieRatingRepository.Add(new MovieRatings(1, 1, 1, DateTime.Now));
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            List <int> expected = new List <int>()
            {
                6, 5, 4, 3, 2, 1
            };
            List <int> actual = movieRatingService.getIdOfTopGradedMovies();

            Assert.Equal(expected, actual);
        }