Пример #1
0
        public void VerifyXML_MeteoData()
        {
            var model = createTestDataModel1Race1Run();

            fillMandatoryFields(model);

            // no eather set, check if weather is absent
            string s = exportToXML(model.GetRace(0));

            Assert.ThrowsException <Xunit.Sdk.TrueException>(() => XmlAssertion.AssertXPathExists("/dsv_alpine_raceresults/racedata/rundata[1]/meteodata", s));

            model.GetRace(0).AdditionalProperties.Weather = "sunny";
            s = exportToXML(model.GetRace(0));
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/meteodata/weather", s, "sunny");


            Assert.ThrowsException <Xunit.Sdk.TrueException>(() => XmlAssertion.AssertXPathExists("/dsv_alpine_raceresults/racedata/rundata[1]/meteodata/snowtexture", s));
            model.GetRace(0).AdditionalProperties.Snow = "griffig";
            s = exportToXML(model.GetRace(0));
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/meteodata/snowtexture", s, "griffig");


            Assert.ThrowsException <Xunit.Sdk.TrueException>(() => XmlAssertion.AssertXPathExists("/dsv_alpine_raceresults/racedata/rundata[1]/meteodata/temperature_startaltitude", s));
            model.GetRace(0).AdditionalProperties.TempStart = "-2";
            s = exportToXML(model.GetRace(0));
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/meteodata/temperature_startaltitude", s, "-2");


            Assert.ThrowsException <Xunit.Sdk.TrueException>(() => XmlAssertion.AssertXPathExists("/dsv_alpine_raceresults/racedata/rundata[1]/meteodata/temperature_finishaltitude", s));
            model.GetRace(0).AdditionalProperties.TempFinish = "-1";
            s = exportToXML(model.GetRace(0));
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/meteodata/temperature_finishaltitude", s, "-1");
        }
Пример #2
0
 [Test] public void AssertXPathEvaluatesToWorksConstantExpression()
 {
     XmlAssertion.AssertXPathEvaluatesTo("true()",
                                         MY_SOLAR_SYSTEM,
                                         "True");
     XmlAssertion.AssertXPathEvaluatesTo("false()",
                                         MY_SOLAR_SYSTEM,
                                         "False");
 }
        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");
        }
Пример #4
0
        public void VerifyXML_MandatoryFields()
        {
            var model = createTestDataModel1Race1Run();

            fillMandatoryFields(model);

            string s = exportToXML(model.GetRace(0));

            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedescription/racedate", s, DateTime.Today.ToString("yyyy-MM-dd"));
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedescription/gender", s, "A");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedescription/raceid", s, "1234");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedescription/raceorganizer", s, "WSV Glonn");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedescription/discipline", s, "RS");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedescription/category", s, "SO");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedescription/racename", s, "Test Race");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedescription/raceplace", s, "Test Location");

            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/useddsvlist", s, "123");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/fvalue", s, "720");

            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/racepenalty[@gender='L']/applied_penalty", s, "0");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/racepenalty[@gender='L']/calculated_penalty", s, "0");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/racepenalty[@gender='M']/applied_penalty", s, "0");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/racepenalty[@gender='M']/calculated_penalty", s, "0");

            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/racejury[@function='ChiefRace']/lastname", s, "Manager");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/racejury[@function='ChiefRace']/firstname", s, "Race");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/racejury[@function='Referee']/lastname", s, "Referee");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/racejury[@function='Referee']/firstname", s, "Race");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/racejury[@function='RepresentativeTrainer']/lastname", s, "Rep");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/racejury[@function='RepresentativeTrainer']/firstname", s, "T.");

            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/coursename", s, "Kurs 1");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/number_of_gates", s, "10");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/number_of_turninggates", s, "9");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/startaltitude", s, "1000");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/finishaltitude", s, "100");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/courselength", s, "1000");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/coursesetter/lastname", s, "Flossmann");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/coursesetter/firstname", s, "Sven");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/coursesetter/club", s, "WSV Glonn");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/forerunner[1]/lastname", s, "Runner");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/forerunner[1]/firstname", s, "F.");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/racedata/rundata[1]/coursedata/forerunner[1]/club", s, "WSV Glonn");
        }
        public void XmlSerializer()
        {
            string xml;

            LiveTimingFIS.LiveTimingFIS lt = new LiveTimingFIS.LiveTimingFIS();

            xml = lt.getXmlKeepAlive();
            XmlAssertion.AssertXPathExists("/livetiming/command/keepalive", xml);


            xml = lt.getXmlClearRace();
            XmlAssertion.AssertXPathExists("/livetiming/command/clear", xml);


            xml = lt.getXmlStatusUpdateInfo("test");
            XmlAssertion.AssertXPathExists("/livetiming/message", xml);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/message", xml, "test");


            TestDataGenerator tg = new TestDataGenerator();
            var rp = tg.createRaceParticipant();
            var r  = tg.Model.GetRace(0);

            r.GetParticipant(1).Participant.Nation = "nation";
            r.GetParticipant(1).Participant.Code   = "123";
            var rr1 = r.GetRun(0);

            xml = lt.getXmlEventOnStart(r.GetParticipant(1));
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/nextstart/@bib", xml, "1");

            xml = lt.getXmlEventStarted(r.GetParticipant(1));
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/start/@bib", xml, "1");

            xml = lt.getXmlStartList(rr1);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/startlist/@runno", xml, rr1.Run.ToString());
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/startlist/racer[1]/@order", xml, "1");
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/startlist/racer[1]/bib", xml, "1");
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/startlist/racer[1]/lastname", xml, r.GetParticipant(1).Name);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/startlist/racer[1]/firstname", xml, r.GetParticipant(1).Firstname);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/startlist/racer[1]/nat", xml, r.GetParticipant(1).Nation);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/startlist/racer[1]/fiscode", xml, r.GetParticipant(1).Code);
        }
Пример #6
0
        public void VerifyXML_Run1()
        {
            TestDataGenerator tg = new TestDataGenerator();

            fillMandatoryFields(tg.Model);

            // Run 1
            tg.Model.GetRace(0).GetRun(0).SetStartFinishTime(tg.createRaceParticipant(cat: tg.findCat('M')), new TimeSpan(0, 8, 0, 0), new TimeSpan(0, 8, 0, 2));
            tg.Model.GetRace(0).GetRun(0).SetStartFinishTime(tg.createRaceParticipant(cat: tg.findCat('M')), new TimeSpan(0, 8, 1, 0), new TimeSpan(0, 8, 1, 4));
            tg.Model.GetRace(0).GetRun(0).SetStartFinishTime(tg.createRaceParticipant(cat: tg.findCat('M')), new TimeSpan(0, 8, 2, 0), new TimeSpan(0, 8, 2, 3));
            tg.Model.GetRace(0).GetRun(0).SetStartFinishTime(tg.createRaceParticipant(cat: tg.findCat('M')), new TimeSpan(0, 8, 2, 0), null);
            tg.Model.GetRace(0).GetRun(0).SetResultCode(tg.Model.GetRace(0).GetParticipant(4), RunResult.EResultCode.NiZ);
            tg.Model.GetRace(0).GetRun(0).SetResultCode(tg.createRaceParticipant(cat: tg.findCat('M')), RunResult.EResultCode.NaS);
            tg.Model.GetRace(0).GetRun(0).SetResultCode(tg.createRaceParticipant(cat: tg.findCat('M')), RunResult.EResultCode.DIS, "Tor 2");

            // Run 2
            tg.Model.GetRace(0).GetRun(1).SetStartFinishTime(tg.Model.GetRace(0).GetParticipant(1), new TimeSpan(0, 9, 0, 0), new TimeSpan(0, 9, 0, 3));
            tg.Model.GetRace(0).GetRun(1).SetStartFinishTime(tg.Model.GetRace(0).GetParticipant(2), new TimeSpan(0, 9, 1, 0), null);
            tg.Model.GetRace(0).GetRun(1).SetResultCode(tg.Model.GetRace(0).GetParticipant(2), RunResult.EResultCode.NiZ);
            tg.Model.GetRace(0).GetRun(1).SetResultCode(tg.Model.GetRace(0).GetParticipant(3), RunResult.EResultCode.DIS, "Tor 1");

            // no eather set, check if weather is absent
            string s = exportToXML(tg.Model.GetRace(0));

            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/raceresults/classified_competitors/ranked[@bib='1']/competitor/lastname", s, "Name 1");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/raceresults/classified_competitors/ranked[@bib='1']/@bib", s, "1");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/raceresults/classified_competitors/ranked[@bib='1']/raceresult/totaltime", s, "00:05.00");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/raceresults/classified_competitors/ranked[@bib='1']/raceresult/runtime[@runnumber='1']", s, "00:02.00");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/raceresults/classified_competitors/ranked[@bib='1']/raceresult/runtime[@runnumber='2']", s, "00:03.00");

            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/raceresults/not_classified_competitiors/notranked[@bib='2']/@status", s, "DNF2");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/raceresults/not_classified_competitiors/notranked[@bib='3']/@status", s, "DSQ2");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/raceresults/not_classified_competitiors/notranked[@bib='4']/@status", s, "DNF1");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/raceresults/not_classified_competitiors/notranked[@bib='5']/@status", s, "DNS1");
            XmlAssertion.AssertXPathEvaluatesTo("/dsv_alpine_raceresults/raceresults/not_classified_competitiors/notranked[@bib='6']/@status", s, "DSQ1");
        }
Пример #7
0
 [Test] public void AssertXPathEvaluatesToWorksForNonMatchingExpression()
 {
     XmlAssertion.AssertXPathEvaluatesTo("//planet[@position='4']/@supportsLife",
                                         MY_SOLAR_SYSTEM,
                                         "");
 }