Esempio n. 1
0
        public async Task Remove_Author()
        {
            var author = await AuthorHelpers.CreateValidAuthor();

            var repository = new AuthorRepository(_fixture.Context);

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

            await AuthorHelpers.RemoveAuthor(author.Id);

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

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

            (await repository.ExistsAsync(author.Id)).Should().BeFalse();
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public async Task Update_Author_DateOfBirth()
        {
            var author = await AuthorHelpers.CreateValidAuthor();

            var repository = new AuthorRepository(_fixture.Context);

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

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

            var authorId = sut.Id;

            sut.Should().NotBeNull();
            sut.DateOfBirth.Should().HaveYear(1973);
            sut.DateOfBirth.Should().HaveMonth(6);
            sut.DateOfBirth.Should().HaveDay(6);

            await AuthorHelpers.UpdateAuthorDateOfBirth(sut.Id, new DateTime(1975, 12, 19));

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

            sut.DateOfBirth.Should().HaveYear(1975);
            sut.DateOfBirth.Should().HaveMonth(12);
            sut.DateOfBirth.Should().HaveDay(19);
            sut.Id.Should().Be(authorId);
        }
Esempio n. 4
0
        public async Task Author_inserted_to_database()
        {
            var author = await AuthorHelpers.CreateValidAuthor();

            var repository = new AuthorRepository(_fixture.Context);

            (await repository.ExistsAsync(author.Id)).Should().BeTrue();
        }
Esempio n. 5
0
        public async Task Author_with_all_properties_inserted_to_database()
        {
            var author = await AuthorHelpers.CreateValidAuthorWithNationality();

            var repository = new AuthorRepository(_fixture.Context);

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

            author.FirstName.Should().Be("Patrick");
            author.LastName.Should().Be("Rothfuss");
            author.DateOfBirth.Should().Be(new DateTime(1973, 6, 6));
            author.MugshotPath.Should().Be(@"\\filepath\file.jpg");
            author.Biography.Should().Be("There is no book number three.");
            author.NotesOld.Should().Be("...");
            author.Nationality.Name.Should().Be("american");
        }
Esempio n. 6
0
        public async Task Update_Author_LastName()
        {
            var author = await AuthorHelpers.CreateValidAuthor();

            var repository = new AuthorRepository(_fixture.Context);

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

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

            var authorId = sut.Id;

            sut.Should().NotBeNull();
            sut.LastName.Should().Be("Rothfuss");

            await AuthorHelpers.UpdateAuthorLastName(sut.Id, "Sanderson");

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

            sut.LastName.Should().Be("Sanderson");
            sut.Id.Should().Be(authorId);
        }
Esempio n. 7
0
        public async Task Update_Author_Notes()
        {
            var author = await AuthorHelpers.CreateValidAuthor();

            var repository = new AuthorRepository(_fixture.Context);

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

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

            var authorId = sut.Id;

            sut.Should().NotBeNull();
            sut.NotesOld.Should().Be("...");

            await AuthorHelpers.UpdateAuthorNotes(sut.Id, "Could I please have book number three?");

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

            sut.NotesOld.Should().Contain("Could I please");
            sut.Id.Should().Be(authorId);
        }
Esempio n. 8
0
        public async Task Update_Author_Biography()
        {
            var author = await AuthorHelpers.CreateValidAuthor();

            var repository = new AuthorRepository(_fixture.Context);

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

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

            var authorId = sut.Id;

            sut.Should().NotBeNull();
            sut.Biography.Should().Contain("There is no book number three.");

            await AuthorHelpers.UpdateAuthorBiography(sut.Id, "Bacon ipsum...");

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

            sut.Biography.Should().Contain("Bacon ipsum");
            sut.Id.Should().Be(authorId);
        }
Esempio n. 9
0
        public async Task Update_Author_MugshotPath()
        {
            var author = await AuthorHelpers.CreateValidAuthor();

            var repository = new AuthorRepository(_fixture.Context);

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

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

            var authorId = sut.Id;

            sut.Should().NotBeNull();
            sut.MugshotPath.Should().Be(@"\\filepath\file.jpg");

            await AuthorHelpers.UpdateAuthorMugshotPath(sut.Id, @"\\filepath\newFile.jpg");

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

            sut.MugshotPath.Should().Be(@"\\filepath\newFile.jpg");
            sut.Id.Should().Be(authorId);
        }