internal void CalculateReferenceTime_AsSpecificDriver_FromRaceData(ReferenceTimeCalculator referenceTimeCalculator,
                                                                           DriverCodeGenerator driverCodeGenerator,
                                                                           LapDataGenerator lapDataGenerator,
                                                                           string team)
        {
            var(drivers, raceData) = BuildRaceData(driverCodeGenerator, lapDataGenerator, team);
            referenceTimeCalculator.SetStrategy(new SpecificDriverAverageReferenceTimeStrategy(drivers.ToArray()[2].DriverCode));
            var referenceTime = referenceTimeCalculator.Calculate(drivers, raceData);

            Assert.Equal(TimeSpan.FromSeconds(17), referenceTime.Time);
        }
        internal void CalculateReferenceTime_AsWinnerAverage_FromRaceData(ReferenceTimeCalculator referenceTimeCalculator,
                                                                          RaceWinnerAverageReferenceTimeStrategy raceWinnerAverageReferenceTimeStrategy,
                                                                          DriverCodeGenerator driverCodeGenerator,
                                                                          LapDataGenerator lapDataGenerator,
                                                                          string team)
        {
            var(drivers, raceData) = BuildRaceData(driverCodeGenerator, lapDataGenerator, team);
            referenceTimeCalculator.SetStrategy(raceWinnerAverageReferenceTimeStrategy);
            var referenceTime = referenceTimeCalculator.Calculate(drivers, raceData);

            Assert.Equal(TimeSpan.FromSeconds(2), referenceTime.Time);
        }
예제 #3
0
 /// <summary>
 /// Initialises a new instance of the <see cref="RaceTraceService"/> object.
 /// </summary>
 /// <param name="lapRepository">The lap time repository.</param>
 /// <param name="driverService">The driver service.</param>
 /// <param name="mapper">The mapper.</param>
 /// <param name="referenceTimeCalculator">The reference time calculator.</param>
 /// <param name="raceTraceFactory">The race trace factory.</param>
 /// <param name="dataIsLoadingObserver">Observer to notify if data is loading.</param>
 public RaceTraceService(ILapRepository lapRepository,
                         IDriverService driverService,
                         DriverLapTimesMapper mapper,
                         ReferenceTimeCalculator referenceTimeCalculator,
                         RaceTraceFactory raceTraceFactory,
                         DataLoadingObserver dataIsLoadingObserver)
 {
     _lapRepository           = lapRepository;
     _driverService           = driverService;
     _mapper                  = mapper;
     _referenceTimeCalculator = referenceTimeCalculator;
     _raceTraceFactory        = raceTraceFactory;
     _dataIsLoadingObserver   = dataIsLoadingObserver;
 }