Пример #1
0
        public async Task Update_Book_Publisher()
        {
            var book = await BookHelpers.CreateValidBook();

            var repository = new BookRepository(_fixture.Context);

            (await repository.ExistsAsync(book.Id)).Should().BeTrue();

            var sut = await repository.LoadAsync(book.Id);

            var bookId = sut.Id;

            sut.Should().NotBeNull();
            sut.Publisher.Should().BeNull();

            var publisher = await PublisherHelpers.CreateValidPublisher();

            await BookHelpers.UpdatePublisher(sut.Id, publisher);

            sut = await repository.LoadAsync(book.Id);

            await _fixture.Context.Entry(sut).ReloadAsync();

            sut.Publisher.Id.Should().Be(publisher.Id);
            sut.Publisher.Name.Should().Be(publisher.Name);
            sut.Id.Should().Be(bookId);
        }
Пример #2
0
        public async Task Update_Book_Language()
        {
            var book = await BookHelpers.CreateValidBook();

            var repository = new BookRepository(_fixture.Context);

            (await repository.ExistsAsync(book.Id)).Should().BeTrue();

            var sut = await repository.LoadAsync(book.Id);

            var bookId = sut.Id;

            sut.Should().NotBeNull();
            sut.Language.Should().BeNull();

            var language = await LanguageHelpers.CreateValidLanguage();

            await BookHelpers.UpdateLanguage(sut.Id, language);

            sut = await repository.LoadAsync(book.Id);

            await _fixture.Context.Entry(sut).ReloadAsync();

            sut.Language.Id.Should().Be(language.Id);
            sut.Language.Name.Should().Be(language.Name);
            sut.Id.Should().Be(bookId);
        }
Пример #3
0
        public async Task Update_Series_Books()
        {
            var series = await SeriesHelpers.CreateValidSeriesWithBooks();

            var repository = new SeriesRepository(_fixture.Context);

            (await repository.ExistsAsync(series.Id)).Should().BeTrue();

            var sut = await repository.LoadAsync(series.Id);

            var seriesId = sut.Id;

            sut.Should().NotBeNull();
            sut.Books.Count.Should().Be(2);

            // Add one more book to series
            var book1 = await BookHelpers.CreateValidBook();

            var book2 = await BookHelpers.CreateValidBook();

            var newReadOrder = new List <ReadOrder>
            {
                ReadOrder.NewReadOrder(book1, null, 3),
                ReadOrder.NewReadOrder(book2, null, 4)
            };
            await SeriesHelpers.UpdateSeriesReadOrder(sut.Id, newReadOrder);

            sut = await repository.LoadAsync(series.Id);

            sut.Books.Count.Should().Be(4);
            sut.Id.Should().Be(seriesId);
        }
Пример #4
0
        public async Task Book_inserted_to_database()
        {
            var book = await BookHelpers.CreateValidBook();

            var repository = new BookRepository(_fixture.Context);

            (await repository.ExistsAsync(book.Id)).Should().BeTrue();
        }
Пример #5
0
        public async Task Update_Book()
        {
            var book = await BookHelpers.CreateValidBook();

            book.Title.Should().Be("Book 1");

            // TODO: Test collections

            // TODO: Update all props, replace collections
            // TODO: Test that collections count is not higher than previously, but items are not the same
            //await BookHelpers.UpdateBook(sut);

            //await _fixture.Context.Entry(book).ReloadAsync();

            //book.Title.Should().Be("Lynch");
        }
Пример #6
0
        public async Task Update_Book_Title()
        {
            var book = await BookHelpers.CreateValidBook();

            var repository = new BookRepository(_fixture.Context);

            (await repository.ExistsAsync(book.Id)).Should().BeTrue();

            var sut = await repository.GetAsync(book.Id);

            var bookId = sut.Id;

            sut.Should().NotBeNull();
            sut.Title.Should().Be("Book 1");

            await BookHelpers.UpdateBookTitle(sut.Id, "Book 1 Limited Edition");

            await _fixture.Context.Entry(sut).ReloadAsync();

            sut.Title.Should().Be("Book 1 Limited Edition");
            sut.Id.Should().Be(bookId);
        }