public IEnumerable <SeriesDto> Build(int count) { var seriesList = new List <SeriesDto>(); var fixture = new Fixture(); for (int i = 0; i < count; i++) { var author = fixture.Build <AuthorDto>() .With(a => a.LibraryId, _libraryId) .Without(a => a.ImageId) .Create(); _connection.AddAuthor(author); _authors.Add(author); FileDto seriesImage = null; if (_withImage) { seriesImage = fixture.Build <FileDto>() .With(a => a.FilePath, Helpers.RandomData.BlobUrl) .With(a => a.IsPublic, true) .Create(); _connection.AddFile(seriesImage); _files.Add(seriesImage); _fileStorage.SetupFileContents(seriesImage.FilePath, Helpers.RandomData.Bytes); _connection.AddFile(seriesImage); } var series = fixture.Build <SeriesDto>() .With(a => a.Name, () => fixture.Create(_namePattern)) .With(s => s.LibraryId, _libraryId) .With(a => a.ImageId, seriesImage?.Id) .Create(); _connection.AddSeries(series); seriesList.Add(series); var books = fixture.Build <BookDto>() .With(b => b.LibraryId, _libraryId) .With(b => b.Language, RandomData.Locale) .Without(b => b.ImageId) .With(b => b.SeriesId, series.Id) .CreateMany(_bookCount); _books.AddRange(books); _connection.AddBooks(books); _connection.AddBooksAuthor(books.Select(b => b.Id), author.Id); } _series.AddRange(seriesList); return(seriesList); }