public void GetNumberOfRatesByReviewerTest(int reviewer, int rate)
        {
            MovieRatingService movieRatingService = new MovieRatingService(repo);
            double             result             = movieRatingService.GetNumberOfRatesByReviewer(reviewer, rate);

            Console.WriteLine(result);
        }
        public void GetNumberOfRatesByReviewer(int reviewer, 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, 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 numberOfRatesByReviewer = mrs.GetNumberOfRatesByReviewer(reviewer, rate);


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

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

            Assert.IsNotNull(result);
        }
        public void GetNumberOfRatesByReviewer(int reviewer, 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(2, 3, 4, DateTime.Now),
                new MovieRating(3, 1, 5, DateTime.Now),
                new MovieRating(3, 2, 5, DateTime.Now),
                new MovieRating(3, 3, 5, DateTime.Now),
                new MovieRating(3, 2, 3, DateTime.Now),
                new MovieRating(4, 1, 2, DateTime.Now),
                new MovieRating(4, 2, 2, DateTime.Now),
                new MovieRating(4, 3, 1, DateTime.Now),
                new MovieRating(4, 4, 1, DateTime.Now),
            };

            MovieRatingService mrs = new MovieRatingService(repoMock.Object);

            // act

            int result = mrs.GetNumberOfRatesByReviewer(reviewer, rate);

            // assert
            Assert.Equal(expected, result);
            repoMock.Verify(repo => repo.Ratings, Times.Once);
        }
        public void GetNumberOfRatesByReviewer()
        {
            MovieRatingService mrs = new MovieRatingService(_repo);
            int rate = 5;

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

            Assert.True(seconds <= MAX_SECONDS);
        }
示例#6
0
        public void GetNumberOfRatesByReviewer(int reviewer, int expected, int rate)
        {
            // arrange
            ratings = new List <MovieRating>()
            {
                new MovieRating(1, 1, 2, DateTime.Now),
                new MovieRating(2, 1, 2, DateTime.Now),
                new MovieRating(3, 2, 3, DateTime.Now),
                new MovieRating(3, 2, 3, DateTime.Now),
            };
            IMovieRatingService mrs = new MovieRatingService(repoMock.Object);

            Assert.Equal(expected, mrs.GetNumberOfRatesByReviewer(reviewer, rate));
            repoMock.Verify(r => r.Ratings, Times.Once);
        }
        public void GetNumberOfRatesByReviewerExpectingArgumentException()
        {
            // arrange
            ratings = new List <MovieRating>()
            {
                new MovieRating(2, 1, 3, DateTime.Now),
                new MovieRating(3, 1, 5, DateTime.Now),
                new MovieRating(3, 2, 5, DateTime.Now),
                new MovieRating(3, 3, 5, DateTime.Now)
            };

            MovieRatingService mrs = new MovieRatingService(repoMock.Object);
            //act

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

            Assert.Equal("No reviews from the reviewer with this rate.", ex.Message);
        }
示例#8
0
        public void GetNumberOfRatesByReviewerWithInvalidRateExpectInvalidDataException(int rate)
        {
            // arrange
            ratings = new List <MovieRating>()
            {
                new MovieRating(1, 1, 2, DateTime.Now),
                new MovieRating(2, 1, 2, DateTime.Now),
                new MovieRating(3, 2, 3, DateTime.Now),
                new MovieRating(3, 2, 3, DateTime.Now),
            };

            IMovieRatingService mrs = new MovieRatingService(repoMock.Object);

            int reviewer = 3;

            var ex = Assert.Throws <InvalidDataException>(() => mrs.GetNumberOfRatesByReviewer(reviewer, rate));

            Assert.Equal("Rate must be in the range 1-5", ex.Message);
            repoMock.Verify(r => r.Ratings, Times.Never);
        }
示例#9
0
        public void GetCountOfGradesGivenByReviewer(int reviewerId, int grade, int amountOfGrades)
        {
            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);

            double actual = movieRatingService.GetNumberOfRatesByReviewer(reviewerId, grade);

            double expected = amountOfGrades;

            Assert.Equal(expected, actual);
        }
示例#10
0
        public void GetNumberOfRatesByReviewer()
        {
            IMovieRatingService movieRatingService = new MovieRatingService(mRepo);

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