private DriverRaceData BuildDriverRaceData(LapDataGenerator lapDataGenerator, string code, params TimeSpan[] timeSpans) { var driverRaceData = new DriverRaceData(new DriverCode(code)); var laps = lapDataGenerator.GenerateLaps(timeSpans); foreach (var(lapCount, lapData) in laps) { driverRaceData.AddLap(lapCount, lapData); } return(driverRaceData); }
public void BuildRaceTrace_CalculatesTrace_ForSingleDriver( RaceTraceFactory raceTraceFactory, DriverCodeGenerator driverCodeGenerator, LapDataGenerator lapDataGenerator, string driverName) { var driverCode = driverCodeGenerator.Generate(); var driverRaceData = new DriverRaceData(driverCode); var laps = lapDataGenerator.GenerateLaps(4); foreach (var(lapTime, lapData) in laps) { driverRaceData.AddLap(lapTime, lapData); } var raceData = new RaceData(driverRaceData); var timeSpan = TimeSpan.FromTicks(TimeSpan.TicksPerMinute); var referenceTime = new ReferenceTime(timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds); var diverLookup = new Dictionary <DriverCode, string> { { driverCode, driverName } }; var raceTrace = raceTraceFactory.Build(raceData, referenceTime, diverLookup); Assert.NotNull(raceTrace); Assert.Equal(1, raceTrace.DriverCodes.Count); var traceData = raceTrace.GetDataForDriver(driverCode); Assert.NotNull(traceData); var traceLapDeltas = traceData.GetAllLaps(); Assert.Equal(4, traceLapDeltas.Count); }