コード例 #1
0
        public void GetTopMovies_ValidNumber_ReturnsTopMoviesBasedOnAverateRating()
        {
            FakeMovieRatingRepository movieRatingRepository = new FakeMovieRatingRepository();

            movieRatingRepository.Add(new MovieRating(1, 7, 5, DateTime.Now));
            movieRatingRepository.Add(new MovieRating(1, 6, 5, DateTime.Now));
            movieRatingRepository.Add(new MovieRating(1, 6, 1, DateTime.Now));
            movieRatingRepository.Add(new MovieRating(1, 6, 4, DateTime.Now));
            movieRatingRepository.Add(new MovieRating(1, 5, 3, DateTime.Now));
            movieRatingRepository.Add(new MovieRating(2, 4, 2, DateTime.Now));
            movieRatingRepository.Add(new MovieRating(2, 3, 3, DateTime.Now));
            movieRatingRepository.Add(new MovieRating(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.GetTopMovies(5);

            Assert.Equal(expected, actual);
        }