public void GetNumberOfReviewsTest(int movie)
        {
            MovieRatingService movieRatingService = new MovieRatingService(repo);
            double             result             = movieRatingService.GetNumberOfReviews(movie);

            Console.WriteLine(result);
        }
        public void GetNumberOfReviews(int movie, int expected)
        {
            //arrange
            IRepository <Rating> repo = repoMock.Object;
            MovieRatingService   mrs  = new MovieRatingService(repo);

            dataStore = new List <Rating>
            {
                new Rating(1, 1, 2, new DateTime(2003, 6, 6)),
                new Rating(1, 3, 3, new DateTime(2005, 9, 6)),
                new Rating(1, 4, 4, new DateTime(2004, 12, 23)),
                new Rating(1, 6, 2, new DateTime(2005, 1, 23)),
                new Rating(3, 5, 2, new DateTime(2005, 2, 23)),
                new Rating(4, 5, 2, new DateTime(2005, 3, 23)),
                new Rating(5, 5, 2, new DateTime(2005, 4, 23)),
                new Rating(6, 5, 2, new DateTime(2005, 5, 23)),
                new Rating(2, 2, 3, new DateTime(2002, 1, 22)),
                new Rating(2, 3, 4, new DateTime(2001, 12, 1))
            };

            //act
            int NumberOfReviews = mrs.GetNumberOfReviews(movie);


            //assert
            Assert.Equal(expected, NumberOfReviews);

            repoMock.Verify(rep => rep.GetAll(), Times.Once);
        }
示例#3
0
        public void GetNumberOfReviews()
        {
            MovieRatingService service = new MovieRatingService(repo);
            var result = service.GetNumberOfReviews(100000);

            Assert.IsNotNull(result);
        }
        public void GetNumberOfReviews()
        {
            MovieRatingService mrs = new MovieRatingService(_repo);

            double seconds = TimeInSeconds(() =>
            {
                double result = mrs.GetNumberOfReviews(_reviewerMostReviews);
            });

            Assert.True(seconds <= MAX_SECONDS);
        }
示例#5
0
        public void GetNumberOfReviews(int movie, int exspected)

        {
            ratings = new List <MovieRating>()
            {
                new MovieRating(1, 2, 1, DateTime.Now),
                new MovieRating(1, 3, 2, DateTime.Now),
                new MovieRating(1, 3, 1, DateTime.Now),
                new MovieRating(1, 3, 2, DateTime.Now),
                new MovieRating(1, 3, 3, DateTime.Now)
            };
            IMovieRatingService mrs = new MovieRatingService(repoMock.Object);

            Assert.Equal(exspected, mrs.GetNumberOfReviews(movie));
            repoMock.Verify(r => r.Ratings, Times.Once);
        }
        public void GetNumberOfReviewsExpectingArgumentException()
        {
            ratings = new List <MovieRating>()
            {
                new MovieRating(1, 2, 3, DateTime.Now),
                new MovieRating(1, 3, 1, DateTime.Now),
                new MovieRating(2, 3, 3, DateTime.Now),
                new MovieRating(3, 3, 5, DateTime.Now)
            };

            MovieRatingService mrs = new MovieRatingService(repoMock.Object);

            var ex = Assert.Throws <ArgumentException>(() => { int result = mrs.GetNumberOfReviews(1); });

            Assert.Equal("No reviews for this movie.", ex.Message);
        }
        public void GetNumberOfReviews(int movie, int expected)
        {
            ratings = new List <MovieRating>()
            {
                new MovieRating(1, 2, 3, DateTime.Now),
                new MovieRating(1, 3, 1, DateTime.Now),
                new MovieRating(2, 3, 3, DateTime.Now),
                new MovieRating(3, 3, 5, DateTime.Now)
            };

            MovieRatingService mrs = new MovieRatingService(repoMock.Object);

            int result = mrs.GetNumberOfReviews(movie);

            Assert.Equal(expected, result);
            repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once);
        }
示例#8
0
        public void GetNumberOfReviews(int movieId, int countOfReviewers)
        {
            MovieRatingRepository movieRatingRepo = new MovieRatingRepository();

            movieRatingRepo.Add(new MovieRating(1, 2, 5, DateTime.Now));
            movieRatingRepo.Add(new MovieRating(1, 3, 3, DateTime.Now));
            movieRatingRepo.Add(new MovieRating(2, 3, 3, DateTime.Now));
            movieRatingRepo.Add(new MovieRating(4, 3, 3, DateTime.Now));
            movieRatingRepo.Add(new MovieRating(2, 2, 4, DateTime.Now));
            movieRatingRepo.Add(new MovieRating(3, 1, 2, DateTime.Now));
            movieRatingRepo.Add(new MovieRating(1, 1, 2, DateTime.Now));
            movieRatingRepo.Add(new MovieRating(3, 3, 3, DateTime.Now));

            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepo);
            int    actualResult   = movieRatingService.GetNumberOfReviews(movieId);
            double expectedResult = countOfReviewers;

            Assert.Equal(expectedResult, actualResult);
        }
        public void GetNumberOfReviews(int movie, int expected)
        {
            // arrange
            ratings = new List <MovieRating>()
            {
                new MovieRating(2, 1, 3, DateTime.Now),
                new MovieRating(2, 2, 4, DateTime.Now),
                new MovieRating(3, 1, 5, DateTime.Now),
                new MovieRating(4, 1, 2, DateTime.Now),
            };

            MovieRatingService mrs = new MovieRatingService(repoMock.Object);

            // act

            int result = mrs.GetNumberOfReviews(movie);

            // assert
            Assert.Equal(expected, result);
            repoMock.Verify(repo => repo.Ratings, Times.Once);
        }
示例#10
0
        public void GetNumberOfReviews()
        {
            IMovieRatingService movieRatingService = new MovieRatingService(mRepo);

            CheckPerformance(() => movieRatingService.GetNumberOfReviews(1), 4000);
        }