public void InvalidMovieID_ThrowsArgumentException()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();
            IMovieRatingService   movieRatingService    = new MovieRatingService(movieRatingRepository);

            Action actual = () => movieRatingService.getCountOfMovieReviewers(-1);

            Assert.Throws <ArgumentException>(actual);
        }
Exemple #2
0
        public void GetNumberOfReviewsFromReviewer_BaitClass()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.AddJSON(movieRatingList);
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            Assert.False(Time(() => movieRatingService.getNumberOfReviewsFromReviewer(1)) < 0);
        }
Exemple #3
0
        public void GetTopGradedMovies_ValidArguments()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.AddJSON(movieRatingList);
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            Assert.True(Time(() => movieRatingService.getIdOfTopGradedMovies()) < 4);
        }
Exemple #4
0
        public void AverageRatingRecievedByMovie_ValidArguments()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.AddJSON(movieRatingList);
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            Assert.True(Time(() => movieRatingService.averageRatingRecievedByMovie(1)) < 4);
        }
Exemple #5
0
        public void GetCountOfGradesGottenByMovie_ValidArgumentse()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.AddJSON(movieRatingList);
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            Assert.True(Time(() => movieRatingService.getCountOfGradesGottenByMovie(9, 1)) < 4);
        }
Exemple #6
0
        public void GetCountOfMovieReviewers_ValidArguments( )
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.AddJSON(movieRatingList);
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            Assert.True(Time(() => movieRatingService.getCountOfMovieReviewers(1)) < 4);
        }
Exemple #7
0
        public void GetAverageRateGivenByReviewer_ValidArguments( )
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.AddJSON(movieRatingList);
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            Assert.True(Time(() => movieRatingService.getAverageRateGivenByReviewer(5)) < 4);
        }
Exemple #8
0
        public void GetNumberOfReviewsFromReviewer_ValidArguments()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

            movieRatingRepository.AddJSON(movieRatingList);
            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository);

            Assert.True(Time(() => movieRatingService.getNumberOfReviewsFromReviewer(2)) < 4);
        }
        public void InvalidReviewerID_ThrowsArgumentException()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();
            IMovieRatingService   movieRatingService    = new MovieRatingService(movieRatingRepository);

            Action actual = () => movieRatingService.getNumberOfReviewsFromReviewer(-1);

            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 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 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 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 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 GetTopReviewers_ValidArguments()
        {
            MovieReviewRepository movieRatingRepository = new MovieReviewRepository();

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

            List <int> expected = new List <int>()
            {
                1, 2, 3
            };
            List <int> actual = movieRatingService.getTopReviewers();

            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);
        }
        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 MovieReviewsController()
 {
     movieReviewRepository = new MovieReviewRepository();
 }