public async Task Setup() { repository = serviceProvider.GetService <IDriversRepository>(); var allDrivers = await repository.GetAll(); foreach (var d in allDrivers) { await repository.Delete(d.Id); } driver = DriverGenerator.Driver; await repository.Create(driver); response = await client.PostAsJsonAsync($"/api/drivers/", driver); }
public async Task <IEnumerable <DriverDto> > GetDrivers() { try { _logger.LogInformation(LoggingEvents.ListItems, "Get all Drivers", null); var drivers = await _driversRepository.GetAll(); if (drivers.Count() == 0) { _logger.LogInformation(LoggingEvents.GetItem, "No Drivers found", null); return(Enumerable.Empty <DriverDto>()); } return(drivers.Select(d => d.Map())); } catch (Exception ex) { _logger.LogError(LoggingEvents.ListItems, ex, ex.Message, null); throw; } }
public async Task OnlyOneItemIsInDb() => (await repository.GetAll()).Count().Should().Be(1);