public void GetReviewersByMovie(int movie, int firstListedReviewer, int lastListedReviewer) { ratings = new List <MovieRating>() { new MovieRating(1, 1, 1, DateTime.Now.AddDays(-1)), //lowest new MovieRating(2, 1, 1, DateTime.Now), new MovieRating(3, 1, 3, DateTime.Now), new MovieRating(4, 1, 5, DateTime.Now.AddDays(-1)), new MovieRating(5, 1, 5, DateTime.Now), //highest new MovieRating(1, 2, 5, DateTime.Now), //highest new MovieRating(2, 2, 5, DateTime.Now.AddDays(-1)), new MovieRating(3, 2, 3, DateTime.Now), new MovieRating(4, 2, 1, DateTime.Now), new MovieRating(5, 2, 1, DateTime.Now.AddDays(-1)), //lowest new MovieRating(1, 3, 1, DateTime.Now), new MovieRating(2, 3, 5, DateTime.Now.AddDays(-1)), new MovieRating(3, 3, 5, DateTime.Now), //highest new MovieRating(4, 3, 1, DateTime.Now.AddDays(-1)), //lowest new MovieRating(5, 3, 3, DateTime.Now) }; IMovieRatingService mrs = new MovieRatingService(repoMock.Object); List <int> results = mrs.GetReviewersByMovie(movie); Assert.Equal(firstListedReviewer, results[0]); Assert.Equal(lastListedReviewer, results[4]); repoMock.Verify(r => r.Ratings, Times.Once); }
public void GetReviewersByMovie(int movie, int[] expected) { //arrange IRepository <Rating> repo = repoMock.Object; MovieRatingService mrs = new MovieRatingService(repo); dataStore = new List <Rating> { new Rating(1, 1, 5, new DateTime(2003, 6, 6)), new Rating(2, 1, 4, new DateTime(2003, 6, 6)), new Rating(3, 1, 3, new DateTime(2003, 6, 6)), new Rating(4, 1, 3, new DateTime(2004, 6, 6)), new Rating(5, 1, 3, new DateTime(2005, 6, 6)), new Rating(1, 2, 1, new DateTime(2003, 6, 6)), new Rating(2, 2, 2, new DateTime(2003, 6, 6)), new Rating(3, 2, 3, new DateTime(2003, 6, 6)), new Rating(4, 2, 4, new DateTime(2004, 6, 6)), new Rating(5, 2, 5, new DateTime(2005, 6, 6)), }; List <int> ReviewersByMovieExpected = new List <int>(expected); //act List <int> ReviewersByMovie = mrs.GetReviewersByMovie(movie); //assert Assert.Equal(ReviewersByMovieExpected, ReviewersByMovie); repoMock.Verify(rep => rep.GetAll(), Times.Once); }
public void GetReviewersByMovie() { MovieRatingService service = new MovieRatingService(repo); var result = service.GetReviewersByMovie(10000); Assert.IsNotNull(result); }
public void GetReviewersByMovie_NegativeNumber_ThrowsArguementException() { FakeMovieRatingRepository movieRatingRepository = new FakeMovieRatingRepository(); IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository); Action actual = () => movieRatingService.GetReviewersByMovie(-1); Assert.Throws <ArgumentException>(actual); }
public void GetReviewersByMovie() { MovieRatingService mrs = new MovieRatingService(_repo); double seconds = TimeInSeconds(() => { List <int> result = mrs.GetReviewersByMovie(_movieMostReviews); }); Assert.True(seconds <= MAX_SECONDS); }
public void GetReviewersByMovie_ValidNumber_ReturnsMovieRatingsOfMovieSorted() { FakeMovieRatingRepository movieRatingRepository = new FakeMovieRatingRepository(); MovieRating movieRating1 = new MovieRating(1, 1, 5, DateTime.Now.AddYears(4)); MovieRating movieRating2 = new MovieRating(2, 1, 5, DateTime.Now.AddYears(3)); MovieRating movieRating3 = new MovieRating(3, 1, 4, DateTime.Now.AddYears(3)); MovieRating movieRating4 = new MovieRating(4, 1, 3, DateTime.Now.AddYears(2)); movieRatingRepository.Add(movieRating1); movieRatingRepository.Add(movieRating2); movieRatingRepository.Add(movieRating3); movieRatingRepository.Add(movieRating4); movieRatingRepository.Add(new MovieRating(3, 2, 1, DateTime.Now)); IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepository); List <MovieRating> expected = new List <MovieRating>() { movieRating1, movieRating2, movieRating3, movieRating4 }; List <MovieRating> actual = movieRatingService.GetReviewersByMovie(1); Assert.Equal(expected, actual); }
public void GetReviewersByMovieExpectingArgumentException() { ratings = new List <MovieRating>() { new MovieRating(2, 4, 5, DateTime.Now), new MovieRating(2, 2, 5, DateTime.Now), new MovieRating(2, 3, 4, DateTime.Now), new MovieRating(3, 2, 1, DateTime.Now), new MovieRating(3, 3, 5, DateTime.Now), new MovieRating(4, 4, 5, DateTime.Parse("31/01/1999", new CultureInfo("da-DK"))), new MovieRating(4, 3, 5, DateTime.Parse("31/01/1998", new CultureInfo("da-DK"))), new MovieRating(4, 2, 4, DateTime.Parse("31/01/1997", new CultureInfo("da-DK"))), new MovieRating(4, 5, 5, DateTime.Parse("31/01/1996", new CultureInfo("da-DK"))), }; MovieRatingService mrs = new MovieRatingService(repoMock.Object); var ex = Assert.Throws <ArgumentException>(() => { List <int> result = mrs.GetReviewersByMovie(1); }); Assert.Equal("No reviews for this movie.", ex.Message); }
public void GetReviewersByMovieTest() { MovieRatingRepository movieRatingRepo = new MovieRatingRepository(); //movieId, reviewerId, grade, realease movieRatingRepo.Add(new MovieRating(1, 2, 5, DateTime.Now.AddDays(3))); movieRatingRepo.Add(new MovieRating(1, 3, 3, DateTime.Now.AddDays(1))); 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, 5, DateTime.Now)); movieRatingRepo.Add(new MovieRating(1, 1, 3, DateTime.Now.AddDays(5))); movieRatingRepo.Add(new MovieRating(3, 3, 5, DateTime.Now)); IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepo); List <int> actual = movieRatingService.GetReviewersByMovie(1); List <int> expected = new List <int> { 2, 3, 1 }; Assert.Equal(expected, actual); }
public void GetReviewersByMovie(int movie, int[] expected) { ratings = new List <MovieRating>() { new MovieRating(2, 1, 5, DateTime.Now), new MovieRating(2, 2, 5, DateTime.Now), new MovieRating(2, 3, 4, DateTime.Now), new MovieRating(3, 2, 1, DateTime.Now), new MovieRating(3, 3, 5, DateTime.Now), new MovieRating(4, 4, 5, DateTime.Parse("31/01/1999", new CultureInfo("da-DK"))), new MovieRating(4, 3, 5, DateTime.Parse("31/01/1998", new CultureInfo("da-DK"))), new MovieRating(4, 2, 4, DateTime.Parse("31/01/1997", new CultureInfo("da-DK"))), new MovieRating(4, 1, 5, DateTime.Parse("31/01/1996", new CultureInfo("da-DK"))), }; MovieRatingService mrs = new MovieRatingService(repoMock.Object); var result = mrs.GetReviewersByMovie(movie).ToArray(); Assert.Equal(expected, result); repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once); }
public void GetReviewersByMovie(int movie, int[] expected) { List <int> expectedList = new List <int>(expected); // arrange ratings = new List <MovieRating>() { new MovieRating(1, 1, 3, DateTime.Now), new MovieRating(2, 1, 5, DateTime.Now), new MovieRating(1, 2, 5, DateTime.Now), new MovieRating(2, 2, 5, DateTime.Now.AddDays(-5)), new MovieRating(1, 3, 4, DateTime.Now), }; MovieRatingService mrs = new MovieRatingService(repoMock.Object); // act List <int> result = mrs.GetReviewersByMovie(movie); // assert Assert.Equal(expectedList, result); repoMock.Verify(repo => repo.Ratings, Times.Once); }
public void GetReviewersByMovie() { IMovieRatingService movieRatingService = new MovieRatingService(mRepo); CheckPerformance(() => movieRatingService.GetReviewersByMovie(1), 4000); }
public void GetReviewersByMovieTest(int movie) { MovieRatingService movieRatingService = new MovieRatingService(repo); List <int> result = movieRatingService.GetReviewersByMovie(movie); }