Beispiel #1
0
        public void GetReviewersByMovie(int movie, 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(1, 2, 1, new DateTime(2020, 1, 1)),
                new MovieRating(1, 3, 3, new DateTime(2020, 1, 1)),
                new MovieRating(2, 3, 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.GetReviewersByMovie(movie);

            Assert.Equal(expected[expectedIndex], result);
            repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once);
        }
Beispiel #2
0
        public void GetReviewersByMovie()
        {
            // arrange
            ratings = new List <MovieRating>()
            {
                new MovieRating(1, 2, 3, DateTime.Now),
                new MovieRating(2, 3, 4, DateTime.Now),
                new MovieRating(3, 3, 5, DateTime.Now.AddDays(-1)),
                new MovieRating(4, 3, 5, DateTime.Now.AddDays(-2)),
                new MovieRating(5, 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>()
            {
                4, 3, 2
            };

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

            // assert
            Assert.Equal(expected, result);
            Assert.Equal(expected2, result2);
            Assert.Equal(expected3, result3);
            repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Exactly(3));
        }
        public void GetReviewersByMovie()
        {
            // arrange
            MovieRatingsService mrs      = new MovieRatingsService(Repo);
            List <int>          expected = new List <int>()
            {
                708, 199, 208, 501, 83
            };

            // act
            var result = mrs.GetReviewersByMovie(MovieWithMostReviews).GetRange(0, 5);

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