public void Should_Validate_Publish_With_Excedent_Authors()
        {
            _publisher = new PublisherBuilder().Build();

            var authorBuilder = new AuthorBuilder().WithPublisher(_publisher);
            var author        = authorBuilder.Build();
            var author2       = authorBuilder.Build();
            var author3       = authorBuilder.Build();
            var author4       = authorBuilder.Build();

            _book = new BookBuilder().Build();

            var authorBookBuilder = new AuthorBookBuilder().WithBook(_book);
            var authorBook        = authorBookBuilder.WithAuthor(author).Build();
            var authorBook2       = authorBookBuilder.WithAuthor(author2).Build();
            var authorBook3       = authorBookBuilder.WithAuthor(author3).Build();
            var authorBook4       = authorBookBuilder.WithAuthor(author4).Build();

            var authorsBook = new List <AuthorBookEntity> {
                authorBook, authorBook2, authorBook3, authorBook4
            };

            _book.AuthorsBook = authorsBook;

            Action act = () => _bookPublishValidator.ValidatePublish(_book, _publisher);

            act.Should()
            .Throw <BusinessException>()
            .WithMessage($"Book can't have more than 3 authors!");
        }
        public void Should_Validate_Publish_With_Excedent_Authors()
        {
            var bookPublishValidator = Resolve <IBookPublishValidator>();
            var bookRepository       = Resolve <IBookRepository>();

            var publisher = new PublisherBuilder().Build();

            var authorBuilder = new AuthorBuilder().WithPublisher(publisher);
            var author        = authorBuilder.Build();
            var author2       = authorBuilder.Build();
            var author3       = authorBuilder.Build();
            var author4       = authorBuilder.Build();

            var book = new BookBuilder().Build();

            var authorBookBuilder = new AuthorBookBuilder().WithBook(book);
            var authorBook        = authorBookBuilder.WithAuthor(author).Build();
            var authorBook2       = authorBookBuilder.WithAuthor(author2).Build();
            var authorBook3       = authorBookBuilder.WithAuthor(author3).Build();
            var authorBook4       = authorBookBuilder.WithAuthor(author4).Build();

            var authorsBook = new List <AuthorBookEntity> {
                authorBook, authorBook2, authorBook3, authorBook4
            };

            AddEntities(publisher, author, author2, author3, author4, book, authorBook, authorBook2, authorBook3, authorBook4);
            book = bookRepository.Get(book.Id).FirstOrDefault();

            Action act = () => bookPublishValidator.ValidatePublish(book, publisher);

            act.Should()
            .Throw <BusinessException>()
            .WithMessage($"Book can't have more than 3 authors!");
        }
        public void Should_Validate_Publish_With_Excedent_Authors()
        {
            var bookBll        = Resolve <IBookBll>();
            var bookRepository = Resolve <IBookRepository>();

            var publisher = new PublisherBuilder().Build();

            var authorBuilder = new AuthorBuilder().WithPublisher(publisher);
            var author        = authorBuilder.Build();
            var author2       = authorBuilder.Build();
            var author3       = authorBuilder.Build();
            var author4       = authorBuilder.Build();

            var book = new BookBuilder().Build();

            var authorBookBuilder = new AuthorBookBuilder().WithBook(book);
            var authorBook        = authorBookBuilder.WithAuthor(author).Build();
            var authorBook2       = authorBookBuilder.WithAuthor(author2).Build();
            var authorBook3       = authorBookBuilder.WithAuthor(author3).Build();
            var authorBook4       = authorBookBuilder.WithAuthor(author4).Build();

            var authorsBook = new List <AuthorBookEntity> {
                authorBook, authorBook2, authorBook3, authorBook4
            };

            AddEntities(publisher, author, author2, author3, author4, book, authorBook, authorBook2, authorBook3, authorBook4);

            Action act = () => bookBll.PublishBook(book.Id, new PublishBookRequestDTO {
                PublishierId = publisher.Id
            });

            act.Should()
            .Throw <BusinessException>()
            .WithMessage($"Book can't have more than 3 authors!");
        }