public void GetAverageRateOfMovie(int movie, double expected)
        {
            // arrange
            MovieRatingsService mrs = new MovieRatingsService(Repo);

            // act
            double result = mrs.GetAverageRateOfMovie(movie);

            // assert
            Assert.AreEqual(expected, result);
        }
Esempio n. 2
0
        public void GetAverageRateOfMovieWithReviews(int movie, double expected)
        {
            ratings = new MovieRating[]
            {
                new MovieRating(1, 2, 3, DateTime.Now),
                new MovieRating(2, 3, 3, DateTime.Now),
                new MovieRating(2, 3, 4, DateTime.Now)
            };
            MovieRatingsService mrs = new MovieRatingsService(repoMock.Object);

            var result = mrs.GetAverageRateOfMovie(movie);

            Assert.Equal(expected, result);
            repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once);
        }
Esempio n. 3
0
        public void GetAverageRatingOfMovieWithNoReviewsExpectArgumentException()
        {
            int movie = 2;

            ratings = new MovieRating[]
            {
                new MovieRating(3, 1, 3, DateTime.Now),
                new MovieRating(3, 3, 4, DateTime.Now)
            };
            MovieRatingsService mrs = new MovieRatingsService(repoMock.Object);

            Action ac = () => mrs.GetAverageRateOfMovie(movie);

            ac.Should().Throw <ArgumentException>().WithMessage($"Movie:{movie} has no reviews");
            repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once);
        }
Esempio n. 4
0
        public void GetAverageRateOfMovie(int movie, double expected)
        {
            // arrange
            ratings = new List <MovieRating>()
            {
                new MovieRating(1, 2, 1, DateTime.Now),
                new MovieRating(2, 3, 4, DateTime.Now),
                new MovieRating(2, 3, 5, DateTime.Now)
            };

            MovieRatingsService mrs = new MovieRatingsService(repoMock.Object);

            // act
            double result = mrs.GetAverageRateOfMovie(movie);

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