Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public async Task Format_inserted_to_database()
        {
            var format = await FormatHelpers.CreateValidFormat();

            var repository = new FormatRepository(_fixture.Context);

            (await repository.ExistsAsync(format.Id)).Should().BeTrue();
        }
Exemplo n.º 3
0
        public async Task Update_Format()
        {
            var format = await FormatHelpers.CreateValidFormat();

            format.Name.Should().Be("paperback");

            var sut = Format.Create(format.Id, "hardcover");

            await FormatHelpers.UpdateFormat(sut);

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

            format.Name.Should().Be("hardcover");
        }
Exemplo n.º 4
0
        public async Task Remove_Format()
        {
            var format = await FormatHelpers.CreateValidFormat();

            var repository = new FormatRepository(_fixture.Context);

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

            await FormatHelpers.RemoveFormat(format.Id);

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

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

            (await repository.ExistsAsync(format.Id)).Should().BeFalse();
        }