Esempio n. 1
0
        public IEnumerable <ChapterDto> Build(int count)
        {
            var fixture = new Fixture();
            var book    = _booksBuilder.WithLibrary(_libraryId).IsPublic(_public).Build();

            for (int i = 0; i < count; i++)
            {
                var chapter = fixture.Build <ChapterDto>()
                              .With(c => c.BookId, book.Id)
                              .With(c => c.ChapterNumber, i + 1)
                              .With(c => c.WriterAccountId, _assignedWriterId)
                              .With(c => c.WriterAssignTimeStamp, _assignedWriterId.HasValue ? DateTime.Now : null)
                              .With(c => c.ReviewerAccountId, _assignedReviewerId)
                              .With(c => c.ReviewerAssignTimeStamp, _assignedReviewerId.HasValue ? DateTime.Now : null)
                              .Create();

                _connection.AddChapter(chapter);
                _chapters.Add(chapter);

                for (int j = 0; j < _contentCount; j++)
                {
                    var content = fixture.Build <ChapterContentDto>()
                                  .With(c => c.ChapterId, chapter.Id)
                                  .With(c => c.Text, RandomData.String)
                                  .With(c => c.Language, _language ?? $"locale-{j}")
                                  .Create();

                    _contents.Add(content);

                    _connection.AddChapterContent(content);
                }
            }

            return(_chapters);
        }