Exemple #1
0
        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());
        }