public void GetLapTimes_ReturnAllDrivers_WhenRequested(string dir, string driverFilePath, string lapTimeFilePath, InfrastructureDriver.RequestFactory driverRequestFactory, InfrastructureDriver.ResponseMapper driverResponseMapper, InfrastructureLap.RequestFactory lapTimeRequestFactory, InfrastructureLap.ResponseMapper lapTimeResponseMapper, int year, int round) { var ergastDriverClient = ErgastClientGenerator.ErgastClientWithResponseFromFile(dir, driverFilePath); var driverClient = new InfrastructureDriver.DriverClient(ergastDriverClient, driverRequestFactory, driverResponseMapper); var ergastLapTimeClient = ErgastClientGenerator.ErgastClientWithResponseFromFile(dir, lapTimeFilePath); var lapTimeClient = new InfrastructureLap.LapTimeClient(ergastLapTimeClient, lapTimeRequestFactory, lapTimeResponseMapper); var lapRepository = new LapRepository(driverClient, lapTimeClient); var lapTimeDictionary = Task.Run(async() => await lapRepository.GetLapTimesAsync(year, round)).Result; Assert.NotNull(lapTimeDictionary); Assert.Equal(20, lapTimeDictionary.Keys.Count()); var driversWithMoreThanOneLap = lapTimeDictionary.Where(x => x.Value.Count > 1).Select(x => x.Key).Distinct().Count(); Assert.Equal(10, driversWithMoreThanOneLap); var hulkenbergLaps = lapTimeDictionary["HUL"].ToArray(); Assert.NotNull(hulkenbergLaps); Assert.Equal(2, hulkenbergLaps.Length); Assert.Equal(9, hulkenbergLaps[0].Position); Assert.Equal(6, hulkenbergLaps[1].Position); }
public void GetCompetingDrivers_ReturnAllDrivers_WhenRequested(string dir, string path) { var client = ErgastClientGenerator.ErgastClientWithResponseFromFile(dir, path); var request = new DriverInfoRequest { Season = "2019", Round = "5" }; var response = Task.Run(async() => await client.GetResponseAsync(request)).Result; Assert.NotNull(response); }
public void GetCompetingDrivers_ReturnAllDrivers_WhenRequestedFromRepository(string dir, string path, RequestFactory requestFactory, ResponseMapper responseMapper) { var client = ErgastClientGenerator.ErgastClientWithResponseFromFile(dir, path); var request = new DriverInfoRequest { Season = "2019", Round = "5" }; var driverRepository = new DriverRepository(new DriverClient(client, requestFactory, responseMapper)); var driverDtoCollection = Task.Run(async() => await driverRepository.GetCompetingDriversAsync(2019, 2)).Result; Assert.NotNull(driverDtoCollection); }
public void GetRaceResults_ForSeason_WhenRequestedFromRepository(string dir, string path, RequestFactory requestFactory, ResponseMapper responseMapper, int year, int round) { var ergastClient = ErgastClientGenerator.ErgastClientWithResponseFromFile(dir, path); var raceClient = new RaceClient(ergastClient, requestFactory, responseMapper); var raceRepository = new RaceRepository(raceClient); var raceResultCollection = Task.Run(async() => await raceRepository.GetRaceResultsForEventAsync(year, round)).Result.ToArray(); Assert.NotNull(raceResultCollection); Assert.Equal(20, raceResultCollection.Count()); Assert.Equal("RIC", raceResultCollection[0].DriverCode); var positions = raceResultCollection.Select(x => x.Position).Distinct().ToArray(); Assert.Equal(20, positions.Count()); Assert.Equal(1, positions.Min()); Assert.Equal(20, positions.Max()); }
public void GetRaceList_ForSeason_WhenRequestedFromRepository(string dir, string path, RequestFactory requestFactory, ResponseMapper responseMapper, int year) { var ergastClient = ErgastClientGenerator.ErgastClientWithResponseFromFile(dir, path); var raceClient = new RaceClient(ergastClient, requestFactory, responseMapper); var raceRepository = new RaceRepository(raceClient); var raceInformationCollection = Task.Run(async() => await raceRepository.GetRaceInformationDtoForSeasonAsync(year)).Result.ToArray(); Assert.NotNull(raceInformationCollection); Assert.Equal(19, raceInformationCollection.Count()); var firstRace = raceInformationCollection.First(); Assert.Equal("Albert Park Grand Prix Circuit", firstRace.Circuit); Assert.Equal("Australia", firstRace.Country); Assert.Equal(9, raceInformationCollection[8].Round); Assert.Equal(new DateTime(2015, 11, 29), raceInformationCollection.Last().Date); }