Ejemplo n.º 1
0
        public async Task Update_Book_Genres()
        {
            var book = await BookHelpers.CreateValidBookWithAllProperties();

            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.Genres.Count.Should().Be(2);

            var genre1 = await GenreHelpers.CreateValidGenre();

            var genre2 = await GenreHelpers.CreateValidGenre();

            var genres = new List <Genre> {
                genre1, genre2
            };
            await BookHelpers.UpdateGenres(sut.Id, genres);

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

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

            sut.Genres.Count.Should().Be(4);
            sut.Id.Should().Be(bookId);
        }