コード例 #1
0
        public async Task Update_Author_Nationality()
        {
            var author = await AuthorHelpers.CreateValidAuthor();

            var repository = new AuthorRepository(_fixture.Context);

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

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

            var authorId = sut.Id;

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

            var nationality = await NationalityHelpers.CreateValidNationality();

            await AuthorHelpers.UpdateAuthorNationality(sut.Id, nationality.Id);

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

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

            sut.Nationality.Id.Should().Be(nationality.Id);
            sut.Nationality.Name.Should().Be(nationality.Name);
            sut.Id.Should().Be(authorId);
        }
コード例 #2
0
        public async Task Nationality_inserted_to_database()
        {
            var nationality = await NationalityHelpers.CreateValidNationality();

            var repository = new NationalityRepository(_fixture.Context);

            (await repository.ExistsAsync(nationality.Id)).Should().BeTrue();
        }
コード例 #3
0
        public async Task Update_Nationality()
        {
            var nationality = await NationalityHelpers.CreateValidNationality();

            nationality.Name.Should().Be("american");

            var sut = Nationality.Create(nationality.Id, "russian");

            await NationalityHelpers.UpdateNationality(sut);

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

            nationality.Name.Should().Be("russian");
        }
コード例 #4
0
        public async Task Remove_Nationality()
        {
            var nationality = await NationalityHelpers.CreateValidNationality();

            var repository = new NationalityRepository(_fixture.Context);

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

            await NationalityHelpers.RemoveNationality(nationality.Id);

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

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

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