Example #1
0
        public IEnumerable <CategoryDto> Build(int count)
        {
            var fixture = new Fixture();

            var cats = fixture.Build <CategoryDto>()
                       .With(c => c.LibraryId, _libraryId)
                       .CreateMany(count);

            _connection.AddCategories(cats);
            _categories.AddRange(cats);

            foreach (var cat in cats)
            {
                var author = fixture.Build <AuthorDto>()
                             .With(a => a.LibraryId, _libraryId)
                             .Without(a => a.ImageId)
                             .Create();

                _connection.AddAuthor(author);
                _authors.Add(author);

                var books = fixture.Build <BookDto>()
                            .With(b => b.LibraryId, _libraryId)
                            .With(b => b.Language, RandomData.Locale)
                            .Without(b => b.ImageId)
                            .Without(b => b.SeriesId)
                            .CreateMany(_bookCount);
                _connection.AddBooks(books);

                _connection.AddBooksAuthor(books.Select(b => b.Id), author.Id);

                _connection.AddBooksToCategory(books, cat);
            }

            return(cats);
        }