Beispiel #1
0
        public void FavoriteBookDto_is_not_valid(FavoriteBookDto dto, string message)
        {
            var result = dto.IsValid();

            result.Should().BeFalse();
            dto.ValidationResult.Errors.Should().NotBeNullOrEmpty();
            dto.ValidationResult.Errors.First().ErrorMessage.Should().Be(message);
        }
Beispiel #2
0
        public void Add(FavoriteBookDto dto)
        {
            if (!dto.IsValid())
            {
                NotifyValidationError(dto);
                return;
            }

            var authors      = string.Join(";", dto.Authors.Select(x => x));
            var favoriteBook = new FavoriteBook(bookId: dto.BookId, link: dto.Link, title: dto.Title, thumbnail: dto.Thumbnail, description: dto.Description, authors: authors, user: dto.User);

            _favoriteBookRepository.Add(favoriteBook);
            Commit();
        }
Beispiel #3
0
        public void FavoriteBookDto_is_valid()
        {
            var dto = new FavoriteBookDto
            {
                Title       = "test",
                Description = "test",
                Authors     = new List <string>()
                {
                    "test", "test2"
                },
                BookId    = "test",
                Link      = "test",
                Thumbnail = "test",
                User      = new UserBuilder().Builder(),
            };

            var result = dto.IsValid();

            result.Should().BeTrue();

            dto.ValidationResult.Errors.Should().BeNullOrEmpty();
        }