Last active
June 2, 2016 21:37
-
-
Save marcduiker/9db3de2f8fb70121e77cd6c6423164b7 to your computer and use it in GitHub Desktop.
Unit test with bulky assert section. The unit test uses Autofixture, FakeItEasy and FluentAssertions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void GetHighestRatedMovies_RepositoryContainsMoviesWithRatings_ReturnsMoviesOrderedByDescendingRating() | |
{ | |
// Arrange | |
var fixture = new Fixture(); | |
var movieCollection = fixture.CreateMany<Movie>(20).ToList(); | |
var fakeMovieRepository = A.Fake<IMovieRepository>(); | |
A.CallTo(() => fakeMovieRepository.GetAll()).Returns(movieCollection); | |
IMovieService movieService = new MovieService(fakeMovieRepository, null, null); | |
MovieServiceRequest request = new MovieServiceRequest { NumberOfMoviesToReturn = 5 }; | |
// Act | |
IList<Movie> movies = movieService.GetHighestRatedMovies(request); | |
// Assert | |
movies.Should().BeInDescendingOrder(movie => movie.Rating); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment