Ejemplo n.º 1
0
        public async Task Update_Book_Read_Dates()
        {
            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.ReadDates.Count.Should().Be(2);

            var readDate1 = new BookReadDate(DateTime.Now);
            var readDate2 = new BookReadDate(DateTime.Now);
            var readDates = new List <BookReadDate> {
                readDate1, readDate2
            };
            await BookHelpers.UpdateReadDates(sut.Id, readDates);

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

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

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