Esempio n. 1
0
        public async Task Setup()
        {
            var author     = AuthorBuilder.WithLibrary(LibraryId).Build();
            var series     = SeriesBuilder.WithLibrary(LibraryId).Build();
            var categories = CategoryBuilder.WithLibrary(LibraryId).Build(3);
            var book       = new BookView
            {
                Title   = RandomData.Name,
                Authors = new List <AuthorView> {
                    new AuthorView {
                        Id = author.Id
                    }
                },
                SeriesId    = series.Id,
                SeriesIndex = 1,
                SeriesName  = series.Name,
                Language    = RandomData.Locale,
                Categories  = RandomData.PickRandom(categories, 2).Select(c => new CategoryView {
                    Id = c.Id
                })
            };

            _response = await Client.PostObject($"/libraries/{LibraryId}/books", book);

            _bookAssert = BookAssert.WithResponse(_response).InLibrary(LibraryId);
        }
Esempio n. 2
0
        public async Task Setup()
        {
            var book = BookBuilder.WithLibrary(LibraryId).WithNoImage().Build();

            _bookId = book.Id;

            _response = await Client.PutFile($"/libraries/{LibraryId}/books/{_bookId}/image", RandomData.Bytes);

            _bookAssert = BookAssert.WithResponse(_response).InLibrary(LibraryId);
        }
        public async Task Setup()
        {
            _categories = CategoryBuilder.WithLibrary(LibraryId).Build(2);
            var books = BookBuilder.WithLibrary(LibraryId)
                        .HavingSeries()
                        .WithCategories(_categories)
                        .WithContents(2)
                        .WithPages()
                        .Build(4);

            _expected = books.PickRandom();

            _response = await Client.GetAsync($"/libraries/{LibraryId}/books/{_expected.Id}");

            _assert = BookAssert.WithResponse(_response).InLibrary(LibraryId);
        }
Esempio n. 4
0
        public async Task Setup()
        {
            var otherAuthor   = AuthorBuilder.WithLibrary(LibraryId).Build();
            var newCategories = CategoryBuilder.WithLibrary(LibraryId).Build(3);
            var otherSeries   = SeriesBuilder.WithLibrary(LibraryId).Build();
            var books         = BookBuilder.WithLibrary(LibraryId)
                                .WithCategories(3)
                                .HavingSeries()
                                .AddToFavorites(AccountId)
                                .AddToRecentReads(AccountId)
                                .Build(1);

            var selectedBook = books.PickRandom();

            _categoriesToUpdate = DatabaseConnection.GetCategoriesByBook(selectedBook.Id).ToList();
            _categoriesToUpdate.AddRange(newCategories);

            var fake = new Faker();

            _expected = new BookView
            {
                Id            = selectedBook.Id,
                Title         = fake.Name.FullName(),
                Description   = fake.Random.Words(5),
                Copyrights    = fake.PickRandom <CopyrightStatuses>().ToDescription(),
                Language      = Helpers.RandomData.Locale,
                YearPublished = fake.Date.Past().Year,
                Status        = fake.PickRandom <BookStatuses>().ToDescription(),
                IsPublic      = fake.Random.Bool(),
                Authors       = new List <AuthorView> {
                    new AuthorView {
                        Id = otherAuthor.Id, Name = otherAuthor.Name
                    }
                },
                SeriesId    = otherSeries.Id,
                IsPublished = fake.Random.Bool(),
                Categories  = _categoriesToUpdate.Select(c => new CategoryView {
                    Id = c.Id
                })
            };

            _response = await Client.PutObject($"/libraries/{LibraryId}/books/{selectedBook.Id}", _expected);

            _bookAssert = BookAssert.WithResponse(_response).InLibrary(LibraryId);
        }
Esempio n. 5
0
        public async Task Setup()
        {
            var author = AuthorBuilder.WithLibrary(LibraryId).Build();

            _expected = new BookView
            {
                Title       = RandomData.Name,
                Description = RandomData.Words(10),
                Authors     = new List <AuthorView> {
                    new AuthorView {
                        Id = author.Id
                    }
                },
                Language = RandomData.Locale
            };

            _response = await Client.PutObject($"/libraries/{LibraryId}/books/{_expected.Id}", _expected);

            _bookAssert = BookAssert.WithResponse(_response).InLibrary(LibraryId);
        }
 public void ShouldBeAddedToFavorites()
 {
     BookAssert.ShouldBeAddedToFavorite(_book.Id, AccountId, DatabaseConnection);
 }
 public void ShouldBeDeletedFromTheRecentReadBooks()
 {
     BookAssert.ShouldHaveDeletedBookFromRecentReads(_expected.Id, DatabaseConnection);
 }
 public void ShouldBeDeletedFromTheFavoritesOfAllUsers()
 {
     BookAssert.ShouldNotBeInFavorites(_expected.Id, AccountId, DatabaseConnection);
 }
 public void ShouldHaveDeletedTheBookImage()
 {
     BookAssert.ShouldHaveDeletedBookImage(_expected.Id, DatabaseConnection);
 }
 public void ShouldBeRemovedFromFavorites()
 {
     BookAssert.ShouldNotBeInFavorites(_book.Id, AccountId, DatabaseConnection);
 }
 public void ShouldHaveUpdatedBookImage()
 {
     BookAssert.ShouldHaveUpdatedBookImage(_bookId, _newImage, DatabaseConnection, FileStore);
 }
Esempio n. 12
0
 public void ShouldHavePublicImage()
 {
     BookAssert.ShouldHavePublicImage(_bookId, DatabaseConnection);
 }
Esempio n. 13
0
 public void ShouldHaveAddedImageToBook()
 {
     BookAssert.ShouldHaveAddedBookImage(_bookId, DatabaseConnection, FileStore);
 }