public void GetAverageRateFromReviewer(int reviewer, double expected) { // arrange MovieRatingsService mrs = new MovieRatingsService(Repo); // act double result = Double.Parse(mrs.GetAverageRateFromReviewer(reviewer).ToString("0.####")); // assert Assert.AreEqual(expected, result); }
public void GetAverageRateFromReviewerWithReviews(int reviewer, double expected) { ratings = new MovieRating[] { new MovieRating(2, 1, 3, DateTime.Now), new MovieRating(3, 1, 3, DateTime.Now), new MovieRating(3, 2, 4, DateTime.Now) }; MovieRatingsService mrs = new MovieRatingsService(repoMock.Object); var result = mrs.GetAverageRateFromReviewer(reviewer); Assert.Equal(expected, result); repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once); }
public void GetAverageRatingFromReviewerWithNoReviewsExpectArgumentException() { int reviewer = 2; ratings = new MovieRating[] { new MovieRating(3, 1, 3, DateTime.Now), new MovieRating(3, 2, 4, DateTime.Now) }; MovieRatingsService mrs = new MovieRatingsService(repoMock.Object); Action ac = () => mrs.GetAverageRateFromReviewer(reviewer); ac.Should().Throw <ArgumentException>().WithMessage($"Reviewer:{reviewer} has no reviews"); repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once); }
public void GetAverageRateFromReviewer(int reviewer, double expected) { // arrange ratings = new List <MovieRating>() { new MovieRating(2, 1, 1, DateTime.Now), new MovieRating(3, 1, 4, DateTime.Now), new MovieRating(3, 2, 5, DateTime.Now), new MovieRating(4, 2, 5, DateTime.Now) }; MovieRatingsService mrs = new MovieRatingsService(repoMock.Object); // act double result = mrs.GetAverageRateFromReviewer(reviewer); // assert Assert.Equal(expected, result); repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once); }