Skip to content

Instantly share code, notes, and snippets.

@marcduiker
Last active June 2, 2016 21:37
Show Gist options
  • Save marcduiker/9db3de2f8fb70121e77cd6c6423164b7 to your computer and use it in GitHub Desktop.
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.
[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