public void NumberOfMoviesWithGrade(int grade, int expected)
        {
            // arrange
            MovieRatingsService mrs = new MovieRatingsService(Repo);

            // act
            int result = mrs.NumberOfMoviesWithGrade(grade);

            // assert
            Assert.AreEqual(expected, result);
        }
Esempio n. 2
0
        public void NumberOfMoviesWithGradeInvalidExpectArgumentException(int grade)
        {
            // arrange
            Mock <IMovieRatingsRepository> repoMock = new Mock <IMovieRatingsRepository>();
            MovieRatingsService            mrs      = new MovieRatingsService(repoMock.Object);

            // act
            var ex = Assert.Throws <ArgumentException>(() =>
            {
                int result = mrs.NumberOfMoviesWithGrade(grade);
            });

            // assert
            Assert.Equal("Grade must be 1 - 5", ex.Message);
        }
Esempio n. 3
0
        public void NumberOfMoviesWithGrade(int grade, int expected)
        {
            // arrange
            ratings = new List <MovieRating>()
            {
                new MovieRating(1, 1, 3, DateTime.Now),
                new MovieRating(2, 1, 3, DateTime.Now),
                new MovieRating(3, 1, 4, DateTime.Now),

                new MovieRating(3, 5, 5, DateTime.Now),
                new MovieRating(3, 2, 5, DateTime.Now),
                new MovieRating(4, 2, 5, DateTime.Now)
            };

            MovieRatingsService mrs = new MovieRatingsService(repoMock.Object);

            // act
            int result = mrs.NumberOfMoviesWithGrade(grade);

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