public void GetNumberOfRatesTest(int movie, int rate)
        {
            MovieRatingService movieRatingService = new MovieRatingService(repo);
            double             result             = movieRatingService.GetNumberOfRates(movie, rate);

            Console.WriteLine(result);
        }
        public void GetNumberOfRates(int movie, int rate, 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, 3, new DateTime(2005, 4, 23)),
                new Rating(6, 5, 3, 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)),
                new Rating(8, 6, 2, new DateTime(2005, 1, 23)),
            };


            //act
            int NumberOfRates = mrs.GetNumberOfRates(movie, rate);

            Assert.Equal(expected, NumberOfRates);

            repoMock.Verify(rep => rep.GetAll(), Times.Once);
        }
Esempio n. 3
0
        public void GetNumberOfRates()
        {
            MovieRatingService service = new MovieRatingService(repo);
            var result = service.GetNumberOfRates(100000, 5);

            Assert.IsNotNull(result);
        }
        public void GetNumberOfRates()
        {
            MovieRatingService mrs = new MovieRatingService(_repo);
            int rate = 1;

            double seconds = TimeInSeconds(() =>
            {
                int result = mrs.GetNumberOfRates(_movieMostReviews, rate);
            });

            Assert.True(seconds <= MAX_SECONDS);
        }
Esempio n. 5
0
        public void GetNumberOfRates(int movie, int rate, 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.GetNumberOfRates(movie, rate));
            repoMock.Verify(r => r.Ratings, Times.Once);
        }
        public void GetNumberOfRatesArgumentException()
        {
            ratings = new List <MovieRating>()
            {
                new MovieRating(1, 2, 3, DateTime.Now),
                new MovieRating(1, 3, 5, DateTime.Now),
                new MovieRating(2, 3, 5, DateTime.Now),
                new MovieRating(3, 3, 5, DateTime.Now)
            };

            MovieRatingService mrs = new MovieRatingService(repoMock.Object);

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

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

            MovieRatingService mrs = new MovieRatingService(repoMock.Object);
            int result             = mrs.GetNumberOfRates(movie, rate);

            Assert.Equal(expetedresult, result);
            repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once);
        }
Esempio n. 8
0
        public void GetNumberOfRatesWithInvalidRateExpectInvalidDataException(int rate)
        {
            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);
            int movie = 1;

            var ex = Assert.Throws <InvalidDataException>(() => mrs.GetNumberOfRates(movie, rate));

            Assert.Equal("Rate must be in the range 1-5", ex.Message);
            repoMock.Verify(r => r.Ratings, Times.Never);
        }
Esempio n. 9
0
        public void GetNumberOfRates(int movieId, int grade, int count)
        {
            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));
            movieRatingRepo.Add(new MovieRating(1, 2, 2, DateTime.Now));

            IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepo);
            double actualResult   = movieRatingService.GetNumberOfRates(movieId, grade);
            double expectedResult = count;

            Assert.Equal(expectedResult, actualResult);
        }
        public void GetNumberOfRates(int movie, int rate, 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, 3, DateTime.Now),
            };

            MovieRatingService mrs = new MovieRatingService(repoMock.Object);

            // act

            int result = mrs.GetNumberOfRates(movie, rate);

            // assert
            Assert.Equal(expected, result);
            repoMock.Verify(repo => repo.Ratings, Times.Once);
        }
Esempio n. 11
0
        public void GetNumberOfRates()
        {
            IMovieRatingService movieRatingService = new MovieRatingService(mRepo);

            CheckPerformance(() => movieRatingService.GetNumberOfRates(1, 2), 3000);
        }