Exemple #1
0
        public async Task ShouldBeCreatedNewAuthor()
        {
            var faker     = new Faker("pt_BR");
            var newAuthor = new AuthorBuilder()
                            .WithId(Guid.NewGuid())
                            .WithFirstName(faker.Person.FirstName)
                            .WithLastName(faker.Person.LastName)
                            .WithEmail(faker.Person.Email)
                            .Build();

            await _authorRepository.CreateAuthorAsync(newAuthor);

            var cmdResult = await _inMemoryDbContext.SaveChangesAsync();

            // Verifica se alguma linha foi afetada
            cmdResult.Should().BeGreaterOrEqualTo(1);

            var createdAuthor = await _authorRepository.GetByIdAsync(newAuthor.Id);

            newAuthor.Should().BeEquivalentTo(createdAuthor, options =>
                                              options.ExcludingMissingMembers());
            createdAuthor.CreatedAt.Should().Be(DateTime.Now.DefaultFormat());
            createdAuthor.UpdatedAt.Should().Be(DateTime.Now.DefaultFormat());
        }