public void LTTransfer_IsEqual() { string getXmlEventResult(uint _startNumber, RaceRun _rr, LiveTimingFIS.LiveTimingFIS _lt) { var _results = ViewUtilities.ViewToList <RunResultWithPosition>(_rr.GetResultView()); var _res = _results.FirstOrDefault(_r => _r.StartNumber == _startNumber); return(_lt.getXmlEventResult(_rr, _res)); } string xml; LiveTimingFIS.LiveTimingFIS lt = new LiveTimingFIS.LiveTimingFIS(); TestDataGenerator tg = new TestDataGenerator(); var rp = tg.createRaceParticipant(); rp.Participant.Code = "123"; var r = tg.Model.GetRace(0); var rr1 = r.GetRun(0); rr1.SetStartFinishTime(r.GetParticipant(1), new TimeSpan(0, 08, 0, 0, 0), new TimeSpan(0, 08, 0, 0, 100)); xml = getXmlEventResult(1, rr1, lt); var t1 = new LiveTimingFIS.LTTransfer(xml); var t2 = new LiveTimingFIS.LTTransfer(xml); Assert.IsTrue(t1.IsEqual(t2)); rr1.SetStartFinishTime(r.GetParticipant(1), new TimeSpan(0, 08, 0, 0, 0), new TimeSpan(0, 08, 0, 0, 110)); xml = getXmlEventResult(1, rr1, lt); var t3 = new LiveTimingFIS.LTTransfer(xml); Assert.IsFalse(t1.IsEqual(t3)); }
public void UpdateInFinish(RaceRun raceRun, RaceParticipant rp) { SetActiveRaceRun(raceRun); var results = ViewUtilities.ViewToList <RaceResultItem>(raceRun.GetRace().GetTotalResultView()); var rri4Participant = results.FirstOrDefault(rri => rri.Participant == rp); scheduleTransfer(new LTTransfer(getXmlEventResult(raceRun, rri4Participant))); }
public void XmlSerializer_EventResult() { string getXmlEventResult(uint _startNumber, RaceRun _rr, LiveTimingFIS.LiveTimingFIS _lt) { var _results = ViewUtilities.ViewToList <RunResultWithPosition>(_rr.GetResultView()); var _res = _results.FirstOrDefault(_r => _r.StartNumber == _startNumber); return(_lt.getXmlEventResult(_rr, _res)); } string xml; LiveTimingFIS.LiveTimingFIS lt = new LiveTimingFIS.LiveTimingFIS(); TestDataGenerator tg = new TestDataGenerator(); var rp = tg.createRaceParticipant(); rp.Participant.Code = "123"; var r = tg.Model.GetRace(0); var rr1 = r.GetRun(0); xml = getXmlEventResult(1, rr1, lt); XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/@bib", xml, "1"); XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/@correction", xml, "y"); XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/time", xml, "0.00"); rr1.SetStartFinishTime(r.GetParticipant(1), new TimeSpan(0, 08, 0, 0, 0), new TimeSpan(0, 08, 0, 0, 100)); xml = getXmlEventResult(1, rr1, lt); XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/time", xml, "0.10"); rr1.SetStartFinishTime(r.GetParticipant(1), new TimeSpan(0, 08, 0, 0, 0), new TimeSpan(0, 08, 0, 30, 100)); xml = getXmlEventResult(1, rr1, lt); XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/time", xml, "30.10"); rr1.SetStartFinishTime(r.GetParticipant(1), new TimeSpan(0, 08, 0, 0, 0), new TimeSpan(0, 08, 1, 30, 100)); xml = getXmlEventResult(1, rr1, lt); XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/time", xml, "1:30.10"); rr1.SetResultCode(r.GetParticipant(1), RunResult.EResultCode.DIS); xml = getXmlEventResult(1, rr1, lt); XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/dq/@bib", xml, "1"); rr1.SetResultCode(r.GetParticipant(1), RunResult.EResultCode.NaS); xml = getXmlEventResult(1, rr1, lt); XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/dns/@bib", xml, "1"); rr1.SetResultCode(r.GetParticipant(1), RunResult.EResultCode.NQ); xml = getXmlEventResult(1, rr1, lt); XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/dns/@bib", xml, "1"); rr1.SetResultCode(r.GetParticipant(1), RunResult.EResultCode.NiZ); xml = getXmlEventResult(1, rr1, lt); XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/dnf/@bib", xml, "1"); }
public void UpdateResults(RaceRun raceRun) { if (!raceRun.HasResults()) { return; } SetActiveRaceRun(raceRun); var results = ViewUtilities.ViewToList <RunResultWithPosition>(raceRun.GetResultView()); RunResultWithPosition lastRR = null; foreach (var rr in results) { if (rr.ResultCode == RunResult.EResultCode.NotSet) { continue; } scheduleTransfer(new LTTransfer(getXmlEventResult(raceRun, rr))); if (lastRR == null || (lastRR.StartTime != null && rr.StartTime != null && lastRR.StartTime < rr.StartTime) ) { lastRR = rr; } } // Update livetiming with last known time if (lastRR != null) { scheduleTransfer(new LTTransfer(getXmlEventResult(raceRun, lastRR))); } }