public void NumberOfMoviesWithGradeInvalidExpectArgumentException(int grade) { // arrange Mock <IMovieRatingRepository> repoMock = new Mock <IMovieRatingRepository>(); MovieRatingService mrs = new MovieRatingService(repoMock.Object); // act var ex = Assert.Throws <ArgumentException>(() => { int result = mrs.NumberOfMoviesWithGrade(grade); }); // assert Assert.Equal("Grade must be 1 - 5", ex.Message); }
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) }; MovieRatingService mrs = new MovieRatingService(repoMock.Object); // act int result = mrs.NumberOfMoviesWithGrade(grade); // assert Assert.Equal(expected, result); repoMock.Verify(repo => repo.Ratings, Times.Once); }