public void AllByTelescope_ShouldReturnValidPublications() { // Arrange StarStuffDbContext db = this.Database; PublicationService publicationService = new PublicationService(db); const int page = 2; const int pageSize = 5; const int telescopeId = 1; Telescope telescope = new Telescope { Id = telescopeId, Discoveries = new List <Discovery> { new Discovery { Publications = this.GetFakePublications() } } }; db.Telescopes.Add(telescope); db.SaveChanges(); List <Publication> fakePublications = this.GetFakePublications() .Skip((page - 1) * pageSize) .Take(pageSize) .ToList(); int i = -1; // Act IEnumerable <ListPublicationsServiceModel> publications = publicationService .AllByTelescope(telescopeId, page, pageSize); // Assert foreach (var actual in publications) { Publication expected = fakePublications[++i]; this.ComparePublications(expected, actual); } }