Esempio n. 1
0
        [InlineData(3, 2)]      // expected[2] = {3, 2, 1}
        public void GetTopMoviesByReviewer(int reviewer, int expectedIndex)
        {
            var expected = new List <int>[]
            {
                new List <int>(),
                new List <int>()
                {
                    1
                },
                new List <int>()
                {
                    3, 2, 1
                }
            };

            ratings = new MovieRating[]
            {
                new MovieRating(2, 1, 1, new DateTime(2020, 1, 1)),
                new MovieRating(3, 1, 3, new DateTime(2020, 1, 1)),
                new MovieRating(3, 2, 4, new DateTime(2020, 1, 2)),
                new MovieRating(3, 3, 4, new DateTime(2020, 1, 1))
            };

            MovieRatingsService mrs = new MovieRatingsService(repoMock.Object);

            var result = mrs.GetTopMoviesByReviewer(reviewer);

            Assert.Equal(expected[expectedIndex], result);
            repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once);
        }
Esempio n. 2
0
        public void GetTopMoviesByReviewer()
        {
            // arrange
            ratings = new List <MovieRating>()
            {
                new MovieRating(2, 1, 5, DateTime.Now),
                new MovieRating(3, 1, 4, DateTime.Now),
                new MovieRating(3, 2, 5, DateTime.Now.AddDays(-1)),
                new MovieRating(3, 3, 5, DateTime.Now.AddDays(-2)),
                new MovieRating(4, 4, 4, DateTime.Now)
            };

            MovieRatingsService mrs = new MovieRatingsService(repoMock.Object);

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

            // act
            var result  = mrs.GetTopMoviesByReviewer(1);
            var result2 = mrs.GetTopMoviesByReviewer(2);
            var result3 = mrs.GetTopMoviesByReviewer(3);

            // assert
            Assert.Equal(expected, result);
            Assert.Equal(expected2, result2);
            Assert.Equal(expected3, result3);
            repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Exactly(3));
        }
        public void GetTopMoviesByReviewer()
        {
            // arrange
            MovieRatingsService mrs      = new MovieRatingsService(Repo);
            List <int>          expected = new List <int>()
            {
                565510, 823941, 471578, 2137809, 912999
            };


            // act
            var result = mrs.GetTopMoviesByReviewer(ReviewerWithMostReviews).GetRange(0, 5);

            // assert
            CollectionAssert.AreEqual(expected, result);
        }