Пример #1
0
        public async Task Update_Book_Formats()
        {
            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.Formats.Count.Should().Be(2);

            var format1 = await FormatHelpers.CreateValidFormat();

            var format2 = await FormatHelpers.CreateValidFormat();

            var formats = new List <Format> {
                format1, format2
            };
            await BookHelpers.UpdateFormats(sut.Id, formats);

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

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

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