Esempio n. 1
0
        public void GetTopRatedMovies()
        {
            // arrange

            ratings = new List <MovieRating>()
            {
                new MovieRating(1, 1, 5, DateTime.Now),
                new MovieRating(2, 1, 4, DateTime.Now),

                new MovieRating(1, 2, 3, DateTime.Now),
                new MovieRating(2, 2, 4, DateTime.Now),

                new MovieRating(1, 3, 2, DateTime.Now),
                new MovieRating(2, 3, 3, DateTime.Now),
                new MovieRating(3, 3, 5, DateTime.Now),

                new MovieRating(2, 4, 5, DateTime.Now)
            };

            MovieRatingsService mrs = new MovieRatingsService(repoMock.Object);

            List <int> expected = new List <int>()
            {
                4, 1, 2, 3
            };

            // act
            var result = mrs.GetTopRatedMovies(4);

            // assert
            Assert.Equal(expected, result);
            repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once);
        }
        public void GetTopRatedMovies()
        {
            // arrange

            MovieRatingsService mrs = new MovieRatingsService(Repo);

            List <int> expected = new List <int>()
            {
                822109, 317050, 383247, 400162, 60343
            };

            // act
            List <int> result = mrs.GetTopRatedMovies(5);

            // assert
            CollectionAssert.AreEqual(expected, result);
        }
Esempio n. 3
0
        public void GetTopRatedMovies(int n, int[] expected)
        {
            ratings = new MovieRating[]
            {
                new MovieRating(1, 2, 3, DateTime.Now),     // movie 1 avg = 4
                new MovieRating(1, 3, 2, DateTime.Now),     // movie 2 avg = 3
                new MovieRating(2, 1, 4, DateTime.Now),     // movie 3 avg = 2.5
                new MovieRating(2, 3, 3, DateTime.Now),     // movie 4 avg = 4.5
                new MovieRating(2, 4, 4, DateTime.Now),
                new MovieRating(3, 4, 5, DateTime.Now)
            };

            MovieRatingsService mrs = new MovieRatingsService(repoMock.Object);

            var result = mrs.GetTopRatedMovies(n);

            Assert.Equal(expected.ToList(), result);
            repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once);
        }