private async Task EnsureAuthorIsCorrectOnDatabaseAsync(AuthorResponse authorResponse)
        {
            var options = new DbContextOptionsBuilder <ControllerTestingDbContext>()
                          .UseSqlServer(_configuration.GetConnectionString("DefaultConnection"))
                          .Options;

            using var dbContext = new ControllerTestingDbContext(options);

            var dbAuthor = await dbContext.Authors
                           .Where(author => author.Id == authorResponse.Id)
                           .FirstOrDefaultAsync();

            authorResponse.Id.Should().Be(dbAuthor.Id);
            authorResponse.FirstName.Should().Be(dbAuthor.FirstName);
            authorResponse.LastName.Should().Be(dbAuthor.LastName);
            authorResponse.DateOfBirth.Date.Should().Be(dbAuthor.DateOfBirth.Date);
        }
Ejemplo n.º 2
0
 public AuthorRepository(ControllerTestingDbContext dbContext)
 => _dbContext = dbContext;
Ejemplo n.º 3
0
 public BookRepository(ControllerTestingDbContext dbContext)
 => _dbContext = dbContext;