public void Returning_to_pits_does_not_set_previous_lap_as_fastest() { // set outlap var manager = new TelemetryLapManager(); foreach (var packet in TelemetryLapHelper.CreateOutLap().Packets) { manager.ProcessIncomingPacket(packet); } // Add nearly all of a lap var firstLap = TelemetryLapHelper.CreatePopulatedLap(lapNumber: 1f, completeLap: true); for (var i = 0; i < firstLap.Packets.Count - 2; i++) { manager.ProcessIncomingPacket(firstLap.Packets[i]); } Assert.IsNull(manager.FastestLap); var garagePacket = new TelemetryPacket { Lap = 0f, Speed = 0f, LapDistance = -0.001f }; Assert.IsTrue(garagePacket.IsSittingInPits); manager.ProcessIncomingPacket(garagePacket); Assert.IsNull(manager.FastestLap); }
public void Can_serialize_lap() { var lap = TelemetryLapHelper.CreatePopulatedLap(1); var serializer = new XmlTelemetryLapRepository(); serializer.Save(lap); }
public void SetUp() { _manager = new TelemetryLapManager(); foreach (var packet in TelemetryLapHelper.CreateOutLap().Packets) { _manager.ProcessIncomingPacket(packet); } foreach (var packet in TelemetryLapHelper.CreatePopulatedLap(lapNumber: 1f).Packets) { _manager.ProcessIncomingPacket(packet); } }
public void Starting_second_full_lap_sets_fastest_lap() { var lap = TelemetryLapHelper.CreatePopulatedLap(lapNumber: 2f); Assert.AreEqual(1f, _manager.LatestPacket.Lap); Assert.IsTrue(lap.IsFirstPacketStartLine); // Lap we just added must be a full lap Assert.IsNull(_manager.FastestLap); // Incoming packet is a new lap _manager.ProcessIncomingPacket(lap.Packets[0]); Assert.IsNotNull(_manager.FastestLap); Assert.AreEqual(1, _manager.FastestLap.LapNumber); Assert.AreEqual(2f, _manager.LatestPacket.Lap); }
public void Start_of_first_full_lap_does_not_set_fastest_lap() { var manager = new TelemetryLapManager(); foreach (var packet in TelemetryLapHelper.CreateOutLap().Packets) { manager.ProcessIncomingPacket(packet); } var fullLap = TelemetryLapHelper.CreatePopulatedLap(lapNumber: 1f); Assert.IsTrue(fullLap.IsFirstPacketStartLine); // Lap we just added must be a full lap manager.ProcessIncomingPacket(fullLap.Packets[0]); Assert.IsNull(manager.FastestLap); }