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); }
public AuthorRepository(ControllerTestingDbContext dbContext) => _dbContext = dbContext;
public BookRepository(ControllerTestingDbContext dbContext) => _dbContext = dbContext;