public void GetTopMoviesByReviewer(int reviewer, int highestMovie, int lowestMovie) { ratings = new List <MovieRating>() { new MovieRating(1, 1, 1, DateTime.Now.AddDays(-1)), //lowest new MovieRating(1, 2, 1, DateTime.Now), new MovieRating(1, 3, 3, DateTime.Now), new MovieRating(1, 4, 5, DateTime.Now.AddDays(-1)), new MovieRating(1, 5, 5, DateTime.Now), //highest new MovieRating(2, 1, 5, DateTime.Now), //highest new MovieRating(2, 2, 5, DateTime.Now.AddDays(-1)), new MovieRating(2, 3, 3, DateTime.Now), new MovieRating(2, 4, 1, DateTime.Now), new MovieRating(2, 5, 1, DateTime.Now.AddDays(-1)), //lowest new MovieRating(3, 1, 5, DateTime.Now.AddDays(-1)), new MovieRating(3, 2, 1, DateTime.Now.AddDays(-1)), //lowest new MovieRating(3, 3, 3, DateTime.Now), new MovieRating(3, 4, 5, DateTime.Now), //highest new MovieRating(3, 5, 1, DateTime.Now) }; IMovieRatingService mrs = new MovieRatingService(repoMock.Object); List <int> results = mrs.GetTopMoviesByReviewer(reviewer); Assert.Equal(highestMovie, results[0]); Assert.Equal(lowestMovie, results[4]); repoMock.Verify(r => r.Ratings, Times.Once); }
public void GetTopMoviesByReviewer(int reviewer, 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(2, 4, 5, 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.GetTopMoviesByReviewer(reviewer).ToArray(); Assert.Equal(expected, result); repoMock.Verify(repo => repo.GetAllMovieRatings(), Times.Once); }
public void GetTopMoviesByReviewer(int reviewer, 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(1, 2, 4, new DateTime(2003, 6, 6)), new Rating(1, 3, 3, new DateTime(2003, 6, 6)), new Rating(1, 4, 3, new DateTime(2004, 6, 6)), new Rating(1, 5, 3, new DateTime(2005, 6, 6)), new Rating(2, 1, 5, new DateTime(2003, 6, 6)), new Rating(2, 2, 5, new DateTime(2004, 6, 6)), new Rating(2, 3, 3, new DateTime(2003, 6, 6)), new Rating(2, 4, 4, new DateTime(2003, 6, 6)), }; List <int> TopRatedMoviesExpected = new List <int>(expected); //act List <int> MostProductiveReviewers = mrs.GetTopMoviesByReviewer(reviewer); //assert Assert.Equal(TopRatedMoviesExpected, MostProductiveReviewers); repoMock.Verify(rep => rep.GetAll(), Times.Once); }
public void GetTopMoviesByReviewer() { MovieRatingService service = new MovieRatingService(repo); var result = service.GetTopMoviesByReviewer(100000); Assert.IsNotNull(result); }
public void GetTopMoviesByReviewer() { MovieRatingService mrs = new MovieRatingService(_repo); double seconds = TimeInSeconds(() => { List <int> result = mrs.GetTopMoviesByReviewer(_reviewerMostReviews); }); Assert.True(seconds <= MAX_SECONDS); }
public void GetTopMoviesByReviewerTest() { MovieRatingRepository movieRatingRepo = new MovieRatingRepository(); //movieId, reviewerId, grade, realease movieRatingRepo.Add(new MovieRating(1, 2, 5, DateTime.Now)); movieRatingRepo.Add(new MovieRating(1, 3, 1, DateTime.Now)); movieRatingRepo.Add(new MovieRating(4, 3, 4, DateTime.Now.AddDays(1))); movieRatingRepo.Add(new MovieRating(3, 3, 4, DateTime.Now)); movieRatingRepo.Add(new MovieRating(2, 2, 4, DateTime.Now)); movieRatingRepo.Add(new MovieRating(3, 1, 5, DateTime.Now.AddDays(1))); movieRatingRepo.Add(new MovieRating(1, 1, 2, DateTime.Now)); movieRatingRepo.Add(new MovieRating(4, 1, 5, DateTime.Now)); IMovieRatingService movieRatingService = new MovieRatingService(movieRatingRepo); List <int> actual = movieRatingService.GetTopMoviesByReviewer(3); List <int> expected = new List <int> { 3, 4, 1 }; Assert.Equal(expected, actual); }
public void GetTopMoviesByReviewerExpectingArgumentException() { 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(2, 4, 5, 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 ex = Assert.Throws <ArgumentException>(() => { List <int> result = mrs.GetTopMoviesByReviewer(1); }); Assert.Equal("This reviewer has not made any reviews yet.", ex.Message); }
public void GetTopMoviesByReviewer(int reviewer, 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, 2, 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.GetTopMoviesByReviewer(reviewer); // assert Assert.Equal(expectedList, result); repoMock.Verify(repo => repo.Ratings, Times.Once); }
public void GetTopMoviesByReviewer() { IMovieRatingService movieRatingService = new MovieRatingService(mRepo); CheckPerformance(() => movieRatingService.GetTopMoviesByReviewer(1), 4000); }
public void GetTopMoviesByReviewerTest(int reviewer) { MovieRatingService movieRatingService = new MovieRatingService(repo); List <int> result = movieRatingService.GetTopMoviesByReviewer(reviewer); }