コード例 #1
0
        public void Integration_1554MSBS()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"1554MSBS.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);
            AppDataModel model = new AppDataModel(db);

            Race race = model.GetRace(0);

            {
                IPDFReport report = new StartListReport(race.GetRun(0));
                Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"1554MSBS - Startliste 1. Durchgang.pdf", 4));
            }
            {
                IPDFReport report = new StartListReport2ndRun(race.GetRun(1));
                Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"1554MSBS - Startliste 2. Durchgang.pdf", 3));
            }
            {
                IPDFReport report = new RaceRunResultReport(race.GetRun(0));
                Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"1554MSBS - Ergebnis 1. Durchgang.pdf", 5));
            }
            {
                IPDFReport report = new RaceRunResultReport(race.GetRun(1));
                Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"1554MSBS - Ergebnis 2. Durchgang.pdf", 3));
            }
            {
                IPDFReport report = new RaceResultReport(race);
                Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"1554MSBS - Ergebnis Gesamt.pdf", 2));
            }
        }
コード例 #2
0
        public void StartNumberAssignment_SaveToRace_Test2()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants_MultipleRacesNoStartnumber.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel model = new AppDataModel(db);
            var          race  = model.GetRaces().FirstOrDefault(r => r.RaceType == Race.ERaceType.GiantSlalom);

            StartNumberAssignment sna = new StartNumberAssignment();

            sna.LoadFromRace(race);

            uint sn = 1;

            foreach (var p in race.GetParticipants())
            {
                sna.Assign(sn, p);
                sn++;
            }
            sna.SaveToRace(race);

            sn = 1;
            foreach (var p in race.GetParticipants())
            {
                Assert.AreEqual(sn, p.StartNumber);
                sn++;
            }
        }
コード例 #3
0
        public void ImportParticpantsWithClassAssignment()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_EmptyManyClasses.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);
            AppDataModel dm = new AppDataModel(db);

            var ir = new ImportReader(@"Teilnehmer_V1_202001301844.csv");

            RaceMapping mapping = new RaceMapping(ir.Columns);

            ClassAssignment cla    = new ClassAssignment(dm.GetParticipantClasses());
            RaceImport      im     = new RaceImport(dm.GetRace(0), mapping, cla);
            var             impRes = im.DoImport(ir.Data);

            Assert.AreEqual(153, impRes.SuccessCount);
            Assert.AreEqual(0, impRes.ErrorCount);

            for (int i = 0; i < 153; i++)
            {
                Participant     p  = dm.GetParticipants()[i];
                RaceParticipant rp = dm.GetRace(0).GetParticipants()[i];

                Assert.AreEqual(string.Format("Name {0}", i + 1), p.Name);
                Assert.AreEqual(string.Format("Name {0}", i + 1), rp.Name);
                Assert.IsTrue(rp.Participant == p);
                Assert.AreSame(cla.DetermineClass(p), p.Class);
                Assert.IsNotNull(p.Class);
            }
        }
コード例 #4
0
        public void StartNumberAssignment_LoadFromRace_Test()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants_MultipleRaces.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel model = new AppDataModel(db);
            var          race  = model.GetRaces().FirstOrDefault(r => r.RaceType == Race.ERaceType.GiantSlalom);

            StartNumberAssignment sna = new StartNumberAssignment();

            sna.LoadFromRace(race);

            var rps = race.GetParticipants().ToList();

            foreach (var snap in sna.ParticipantList)
            {
                if (snap.StartNumber != 0)
                {
                    var rp = rps.FirstOrDefault(x => x.StartNumber == snap.StartNumber);
                    Assert.AreEqual(snap.Participant, rp);
                }
            }

            Assert.IsFalse(sna.DifferentToRace(race));
            sna.Assign(1000, race.GetParticipant(1));
            Assert.IsTrue(sna.DifferentToRace(race));
            sna.LoadFromRace(race);
            Assert.IsFalse(sna.DifferentToRace(race));
            sna.DeleteAll();
            Assert.IsTrue(sna.DifferentToRace(race));
        }
コード例 #5
0
        public void GlobalRaceConfig_SaveAndLoad()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_Empty.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);
            AppDataModel model = new AppDataModel(db);

            // Default Config
            Assert.AreEqual("Vereinsrennen - BestOfTwo", model.GlobalRaceConfig.Name);

            var testConfig1 = new RaceConfiguration
            {
                Name            = "BaseName",
                Runs            = 2,
                DefaultGrouping = "DefaultG",
                ActiveFields    = new List <string> {
                    "eins", "zwei"
                },
                RaceResultView       = "RaceResultView",
                RaceResultViewParams = new Dictionary <string, object>(),

                Run1_StartistView         = "Run1_StartistView",
                Run1_StartistViewGrouping = "Run1_StartistViewGrouping",
                Run1_StartistViewParams   = new Dictionary <string, object>(),

                Run2_StartistView         = "Run2_StartistView",
                Run2_StartistViewGrouping = "Run2_StartistViewGrouping",
                Run2_StartistViewParams   = new Dictionary <string, object>(),

                LivetimingParams = new Dictionary <string, string> {
                    { "key", "value" }
                },

                ValueF         = 100,
                ValueA         = 200,
                MinimumPenalty = 300
            };

            // Check for PropertyChanged event
            string propertyChanged = null;

            model.PropertyChanged += delegate(object sender, System.ComponentModel.PropertyChangedEventArgs e)
            {
                propertyChanged = e.PropertyName;
            };

            model.GlobalRaceConfig = testConfig1;
            Assert.AreEqual("GlobalRaceConfig", propertyChanged);

            TestUtilities.AreEqualByJson(testConfig1, model.GlobalRaceConfig);
            model.Close();

            // Check saving and loading from in DB
            RaceHorologyLib.Database db2 = new RaceHorologyLib.Database();
            db2.Connect(dbFilename);
            AppDataModel model2 = new AppDataModel(db2);

            TestUtilities.AreEqualByJson(testConfig1, model2.GlobalRaceConfig);
        }
コード例 #6
0
        public void StartNumberAssignment_ParticpantSelector1_Test()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"1554MSBS.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel model = new AppDataModel(db);
            var          race  = model.GetRace(0);

            StartNumberAssignment sna = new StartNumberAssignment();

            sna.LoadFromRace(race);

            ParticipantSelector ps = new ParticipantSelector(race, sna, "Class");

            foreach (var g in ps.Group2Participant)
            {
                foreach (var rp in g.Value)
                {
                    Assert.AreEqual(rp.Class, g.Key);
                }
            }

            ParticipantSelector ps2 = new ParticipantSelector(race, sna, "Sex");

            foreach (var g in ps2.Group2Participant)
            {
                foreach (var rp in g.Value)
                {
                    Assert.AreEqual(rp.Sex, g.Key);
                }
            }

            ParticipantSelector ps3 = new ParticipantSelector(race, sna, null);

            foreach (var g in ps3.Group2Participant)
            {
                Assert.AreEqual("", g.Key);
                Assert.AreEqual(race.GetParticipants().Count, g.Value.Count);
            }

            ps3.GroupProperty = "Sex";
            foreach (var g in ps3.Group2Participant)
            {
                foreach (var rp in g.Value)
                {
                    Assert.AreEqual(rp.Sex, g.Key);
                }
            }

            // TEST: Iterating through groups
            Assert.AreEqual(((ParticipantCategory)ps2.CurrentGroup).Name, 'W');
            Assert.IsTrue(ps2.SwitchToNextGroup());
            Assert.AreEqual(((ParticipantCategory)ps2.CurrentGroup).Name, 'M');
            Assert.IsFalse(ps2.SwitchToNextGroup());
            Assert.IsNull(ps2.CurrentGroup);
        }
コード例 #7
0
        public void StartNumberAssignment_Manual_Test()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants_MultipleRacesNoStartnumber.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel model = new AppDataModel(db);
            var          rps   = model.GetRace(0).GetParticipants().ToList();


            StartNumberAssignment sna = new StartNumberAssignment();

            uint sn = sna.AssignNextFree(rps[0]);

            Assert.AreEqual(1U, sn);
            Assert.AreEqual(rps[0], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 1).Participant);

            sn = sna.AssignNextFree(rps[1]);
            Assert.AreEqual(2U, sn);
            Assert.AreEqual(rps[1], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 2).Participant);

            sna.Assign(4U, rps[2]);
            Assert.AreEqual(rps[2], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 4).Participant);

            sn = sna.AssignNextFree(rps[3]);
            Assert.AreEqual(5U, sn);
            Assert.AreEqual(rps[3], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 5).Participant);

            sna.InsertAndShift(2U);
            Assert.AreEqual(rps[0], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 1).Participant);
            Assert.AreEqual(null, sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 2).Participant);
            Assert.AreEqual(rps[1], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 3).Participant);
            Assert.AreEqual(null, sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 4).Participant);
            Assert.AreEqual(rps[2], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 5).Participant);
            Assert.AreEqual(rps[3], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 6).Participant);

            sna.Assign(1U, null);
            Assert.AreEqual(null, sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 1).Participant);
            Assert.AreEqual(null, sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 2).Participant);
            Assert.AreEqual(rps[1], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 3).Participant);
            Assert.AreEqual(null, sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 4).Participant);
            Assert.AreEqual(rps[2], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 5).Participant);
            Assert.AreEqual(rps[3], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 6).Participant);

            sna.Delete(1U);
            Assert.AreEqual(null, sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 1).Participant);
            Assert.AreEqual(rps[1], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 2).Participant);
            Assert.AreEqual(null, sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 3).Participant);
            Assert.AreEqual(rps[2], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 4).Participant);
            Assert.AreEqual(rps[3], sna.ParticipantList.FirstOrDefault(v => v?.StartNumber == 5).Participant);
        }
コード例 #8
0
        public void Race_ManageRun_DataHandling()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants_MultipleRaces.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel dm   = new AppDataModel(db);
            var          race = dm.GetRaces().FirstOrDefault(r => r.RaceType == Race.ERaceType.GiantSlalom);

            // Check correct initial assumptions
            Assert.AreEqual(4, dm.GetRaces().Count);
            Assert.AreEqual(2, race.GetMaxRun());

            RaceParticipant p1 = race.GetParticipant(1);

            Assert.AreEqual(new TimeSpan(0, 0, 0, 22, 850), race.GetRun(0).GetRunResult(p1).GetRunTime());
            Assert.AreEqual(new TimeSpan(0, 0, 0, 21, 950), race.GetRun(1).GetRunResult(p1).GetRunTime());

            race.DeleteRaceRun();
            Assert.AreEqual(1, race.GetMaxRun());
            Assert.AreEqual(new TimeSpan(0, 0, 0, 22, 850), race.GetRun(0).GetRunResult(p1).GetRunTime());


            race.AddRaceRun();
            Assert.AreEqual(2, race.GetMaxRun());
            Assert.AreEqual(new TimeSpan(0, 0, 0, 22, 850), race.GetRun(0).GetRunResult(p1).GetRunTime());
            Assert.AreEqual(new TimeSpan(0, 0, 0, 21, 950), race.GetRun(1).GetRunResult(p1).GetRunTime());


            // Perform Modification and Check again
            race.GetRun(1).SetRunTime(p1, new TimeSpan(0, 0, 0, 10, 110));
            Assert.AreEqual(new TimeSpan(0, 0, 0, 10, 110), race.GetRun(1).GetRunResult(p1).GetRunTime());

            race.DeleteRaceRun();
            Assert.AreEqual(1, race.GetMaxRun());
            Assert.AreEqual(new TimeSpan(0, 0, 0, 22, 850), race.GetRun(0).GetRunResult(p1).GetRunTime());

            race.AddRaceRun();
            Assert.AreEqual(2, race.GetMaxRun());
            Assert.AreEqual(new TimeSpan(0, 0, 0, 22, 850), race.GetRun(0).GetRunResult(p1).GetRunTime());
            Assert.AreEqual(new TimeSpan(0, 0, 0, 10, 110), race.GetRun(1).GetRunResult(p1).GetRunTime());

            //race.UpdateNumberOfRuns(3);
            //Assert.AreEqual(3, race.GetMaxRun());

            //race.UpdateNumberOfRuns(2);
            //Assert.AreEqual(2, race.GetMaxRun());
        }
コード例 #9
0
        public void Race_DeactivatedParticipant()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_DeactivatedParticipants.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel model = new AppDataModel(db);
            var          race  = model.GetRace(0);

            void verifyParticpants_1()
            {
                Assert.AreEqual(2, model.GetParticipants().Count);
                Assert.AreEqual(1, race.GetParticipants().Count);
                Assert.AreEqual(1, race.GetRun(0).GetResultList().Count);
                Assert.AreEqual("N1", race.GetRun(0).GetResultList()[0].Participant.Name);
            }

            void verifyParticpants_2()
            {
                Assert.AreEqual(2, race.GetParticipants().Count);
                Assert.AreEqual(2, race.GetRun(0).GetResultList().Count);
                {
                    var rr = race.GetRun(0).GetResultList().First((p) => p.Name == "N1");
                    Assert.AreEqual("N1", rr.Participant.Name);
                    Assert.IsNotNull(rr.Runtime);
                }
                {
                    var rr = race.GetRun(0).GetResultList().First((p) => p.Name == "N2");
                    Assert.AreEqual("N2", rr.Participant.Name);
                    Assert.IsNotNull(rr.Runtime);
                }
            }

            verifyParticpants_1();
            // Add the race participant, check whether the time is available
            race.AddParticipant(model.GetParticipants().First((p) => p.Name == "N2"));
            verifyParticpants_2();

            // Remove participant
            race.RemoveParticipant(model.GetParticipants().First((p) => p.Name == "N2"));
            verifyParticpants_1();

            // Re-add/re-enable the race participant, check whether the saved time data is available
            race.AddParticipant(model.GetParticipants().First((p) => p.Name == "N2"));
            verifyParticpants_2();
        }
コード例 #10
0
        public void GlobalRaceConfig_DSVAlpinImport()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_Empty.mdb");

            AppDataModel configDBAndGetModel(CompetitionProperties.ECompetitionType type)
            {
                RaceHorologyLib.Database db = new RaceHorologyLib.Database();
                db.Connect(dbFilename);

                var compProp = db.GetCompetitionProperties();

                compProp.Type = type;
                db.UpdateCompetitionProperties(compProp);

                return(new AppDataModel(db));
            }

            AppDataModel model;

            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.FIS_Women);
            Assert.AreEqual("FIS Rennen - Damen", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.FIS_Men);
            Assert.AreEqual("FIS Rennen - Herren", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.DSV_Points);
            Assert.AreEqual("DSV Erwachsene", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.DSV_NoPoints);
            Assert.AreEqual("DSV Erwachsene", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.DSV_SchoolPoints);
            Assert.AreEqual("DSV Schüler U14-U16", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.DSV_SchoolNoPoints);
            Assert.AreEqual("DSV Schüler U14-U16", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.VersatilityPoints);
            Assert.AreEqual(null, model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.VersatilityNoPoints);
            Assert.AreEqual(null, model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.ClubInternal_BestRun);
            Assert.AreEqual("Vereinsrennen - BestOfTwo", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.ClubInternal_Sum);
            Assert.AreEqual("Vereinsrennen - Summe", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.Parallel);
            Assert.AreEqual(null, model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.Sledding_NoPoints);
            Assert.AreEqual(null, model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.Sledding_Points);
            Assert.AreEqual(null, model.GlobalRaceConfig.Name);
        }
コード例 #11
0
        public void StartNumberAssignment_ParticpantSelector2_Test()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"1554MSBS.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel model = new AppDataModel(db);
            var          race  = model.GetRace(0);

            StartNumberAssignment sna = new StartNumberAssignment();

            sna.LoadFromRace(race);

            sna.DeleteAll();

            ParticipantSelector ps = new ParticipantSelector(race, sna, "Class");

            Assert.AreEqual(ps.CurrentGroup.ToString(), "U14 weiblich Jg. 07");
            ps.AssignParticipants();
            Assert.IsTrue(ps.SwitchToNextGroup());
            Assert.AreEqual(ps.CurrentGroup.ToString(), "U14 weiblich Jg. 06");
            ps.AssignParticipants();
            Assert.IsTrue(ps.SwitchToNextGroup());
            Assert.AreEqual(ps.CurrentGroup.ToString(), "U16 weiblich  Jg. 05/04");
            ps.AssignParticipants();
            Assert.IsTrue(ps.SwitchToNextGroup());
            Assert.AreEqual(ps.CurrentGroup.ToString(), "U14 männlich Jg. 07");
            ps.AssignParticipants();
            Assert.IsTrue(ps.SwitchToNextGroup());
            Assert.AreEqual(ps.CurrentGroup.ToString(), "U14 männlich Jg. 06");
            ps.AssignParticipants();
            Assert.IsTrue(ps.SwitchToNextGroup());
            Assert.AreEqual(ps.CurrentGroup.ToString(), "U16 männlich Jg. 05/04");
            ps.AssignParticipants();
            Assert.IsFalse(ps.SwitchToNextGroup());
            Assert.IsNull(ps.CurrentGroup);

            // Check once more
            Assert.IsFalse(ps.SwitchToNextGroup());
            Assert.IsNull(ps.CurrentGroup);
        }
コード例 #12
0
        public void JsonConversion()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel dataModel = new AppDataModel(db);
            Race         race      = dataModel.GetCurrentRace();
            RaceRun      rr1       = race.GetRun(0);

            string jsonStart  = RaceHorologyLib.JsonConversion.ConvertStartList(rr1.GetStartList());
            string jsonResult = RaceHorologyLib.JsonConversion.ConvertRunResults(rr1.GetResultView());

            //string jsonStartExpected = @"{""type"":""startlist"",""data"":[{""Id"":""1"",""StartNumber"":1,""Name"":""Nachname 1"",""Firstname"":""Vorname 1"",""Sex"":""W"",""Year"":2009,""Club"":""Verein 1"",""Nation"":""Nation 1"",""Class"":""Mädchen 2009"",""Group"":""U10 weiblich""},{""Id"":""2"",""StartNumber"":2,""Name"":""Nachname 2"",""Firstname"":""Vorname 2"",""Sex"":""M"",""Year"":2013,""Club"":""Verein 2"",""Nation"":""Nation 2"",""Class"":""Buben 2013"",""Group"":""Bambini männlich""},{""Id"":""3"",""StartNumber"":3,""Name"":""Nachname 3"",""Firstname"":""Vorname 3"",""Sex"":""M"",""Year"":2011,""Club"":""Verein 3"",""Nation"":""Nation 3"",""Class"":""Buben 2011"",""Group"":""U8 männlich""},{""Id"":""4"",""StartNumber"":4,""Name"":""Nachname 4"",""Firstname"":""Vorname 4"",""Sex"":""W"",""Year"":2014,""Club"":""Verein 4"",""Nation"":""Nation 4"",""Class"":""Mädchen 2014"",""Group"":""Bambini weiblich""},{""Id"":""5"",""StartNumber"":5,""Name"":""Nachname 5"",""Firstname"":""Vorname 5"",""Sex"":""M"",""Year"":2012,""Club"":""Verein 5"",""Nation"":""Nation 5"",""Class"":""Buben 2012"",""Group"":""U8 männlich""}]}";
            //string jsonResultExpected = @"{""type"":""racerunresult"",""data"":[{""Id"":""1"",""Position"":1,""StartNumber"":""1"",""Name"":""Nachname 1"",""Firstname"":""Vorname 1"",""Sex"":""W"",""Year"":2009,""Club"":""Verein 1"",""Nation"":""Nation 1"",""Class"":""Mädchen 2009"",""Group"":""U10 weiblich"",""Runtime"":""00:22,85"",""DisqualText"":null,""JustModified"":false},{""Id"":""4"",""Position"":2,""StartNumber"":""4"",""Name"":""Nachname 4"",""Firstname"":""Vorname 4"",""Sex"":""W"",""Year"":2014,""Club"":""Verein 4"",""Nation"":""Nation 4"",""Class"":""Mädchen 2014"",""Group"":""Bambini weiblich"",""Runtime"":""00:29,88"",""DisqualText"":null,""JustModified"":false},{""Id"":""2"",""Position"":3,""StartNumber"":""2"",""Name"":""Nachname 2"",""Firstname"":""Vorname 2"",""Sex"":""M"",""Year"":2013,""Club"":""Verein 2"",""Nation"":""Nation 2"",""Class"":""Buben 2013"",""Group"":""Bambini männlich"",""Runtime"":""00:39,11"",""DisqualText"":null,""JustModified"":false},{""Id"":""3"",""Position"":0,""StartNumber"":""3"",""Name"":""Nachname 3"",""Firstname"":""Vorname 3"",""Sex"":""M"",""Year"":2011,""Club"":""Verein 3"",""Nation"":""Nation 3"",""Class"":""Buben 2011"",""Group"":""U8 männlich"",""Runtime"":null,""DisqualText"":null,""JustModified"":false}]}";

            //Assert.AreEqual(jsonStartExpected, jsonStart);
            //Assert.AreEqual(jsonResultExpected, jsonResult);
        }
コード例 #13
0
        public void ChangeStartNumber()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants_MultipleRacesNoStartnumber.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel model = new AppDataModel(db);
            var          rps   = model.GetRace(0).GetParticipants().ToList();

            // Assign startnumber from scratch
            rps.Sort(Comparer <RaceParticipant> .Create((x, y) => x.Name.CompareTo(y.Name)));
            for (int i = 0; i < rps.Count; i++)
            {
                Assert.AreEqual(0U, rps[i].StartNumber, "pre-condition check of unassigned startnumber");
                rps[i].StartNumber = (uint)i + 1;
            }

            // TEST 1: Test whether startnumber is remembered
            for (int i = 0; i < rps.Count; i++)
            {
                Assert.AreEqual((uint)i + 1, rps[i].StartNumber);
            }

            db.Close();
            model = null;

            // TEST 2: Cross-Check whether the startnumbers have been stored in DataBase
            RaceHorologyLib.Database db2 = new RaceHorologyLib.Database();
            db2.Connect(dbFilename);
            AppDataModel model2 = new AppDataModel(db2);
            var          rps2   = model2.GetRace(0).GetParticipants().ToList();

            Assert.AreEqual(rps.Count, rps2.Count);

            rps2.Sort(Comparer <RaceParticipant> .Create((x, y) => x.Name.CompareTo(y.Name)));
            for (int i = 0; i < rps2.Count; i++)
            {
                Assert.AreEqual((uint)i + 1, rps2[i].StartNumber);
            }
        }
コード例 #14
0
        public void RaceParticpant1()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants_MultipleRacesNoStartnumber.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel model = new AppDataModel(db);
            var          race  = model.GetRace(0);

            Assert.AreEqual(Race.ERaceType.DownHill, race.RaceType); // Check that the correct race has been selected

            var rps = race.GetParticipants().ToList();

            rps.Sort(Comparer <RaceParticipant> .Create((x, y) => x.Name.CompareTo(y.Name)));

            // TEST: Remove particpant
            race.GetParticipants().Remove(rps[0]); // "Nachname 1"
            Assert.IsNull(race.GetParticipants().FirstOrDefault(p => p.Name == "Nachname 1"));

            // TEST: Add particpant
            var p7 = model.GetParticipants().First(p => p.Name == "Nachname 7");

            race.AddParticipant(p7);
            Assert.IsNotNull(race.GetParticipants().FirstOrDefault(p => p.Name == "Nachname 7"));

            model = null;
            db.Close();


            // TEST: Cross-Check whether the startnumbers have been stored in DataBase
            RaceHorologyLib.Database db2 = new RaceHorologyLib.Database();
            db2.Connect(dbFilename);
            AppDataModel model2 = new AppDataModel(db2);

            Assert.IsNull(model2.GetRace(0).GetParticipants().FirstOrDefault(p => p.Name == "Nachname 1"));
            Assert.IsNotNull(model2.GetRace(0).GetParticipants().FirstOrDefault(p => p.Name == "Nachname 7"));
            return;
        }
コード例 #15
0
        public void ImportRace()
        {
            var    db         = new RaceHorologyLib.Database();
            string dbFilename = db.CreateDatabase("new.mdb");

            db.Connect(dbFilename);

            //RaceHorologyLib.IAppDataModelDataBase db = new RaceHorologyLib.DatabaseDummy("./");

            AppDataModel dm = new AppDataModel(db);

            // Create a Race
            dm.AddRace(new Race.RaceProperties {
                RaceType = Race.ERaceType.GiantSlalom, Runs = 2
            });

            ImportResults impRes = new ImportResults();

            TimeSpan time = TestUtilities.Time(() =>
            {
                var ir = new ImportReader(@"Teilnehmer_V1_202001301844.csv");
                RaceMapping mapping = new RaceMapping(ir.Columns);

                RaceImport im = new RaceImport(dm.GetRace(0), mapping);
                impRes        = im.DoImport(ir.Data);
            });

            Assert.AreEqual(153, impRes.SuccessCount);
            Assert.AreEqual(0, impRes.ErrorCount);

            Assert.IsTrue(dm.GetParticipants().Count() == 153);
            Assert.IsTrue(dm.GetRace(0).GetParticipants().Count() == 153);

            TestContext.WriteLine(string.Format("Import took: {0:0.00} sec", time.TotalSeconds));
            Assert.IsTrue(time.TotalSeconds < 4);

            //db.Close();
        }
コード例 #16
0
        public void TestSerialization()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants_LiveTiming.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);
            AppDataModel model = new AppDataModel(db);

            model.SetCurrentRace(model.GetRaces()[0]);
            model.SetCurrentRaceRun(model.GetCurrentRace().GetRun(0));

            LiveTimingRM cl = new LiveTimingRM();

            cl.Race = model.GetCurrentRace();

            string classes = cl.getClasses();

            Assert.AreEqual(
                "Klasse|20|Mädchen 2014|1\n" +
                "Klasse|18|Buben 2014|2\n" +
                "Klasse|19|Mädchen 2013|3\n" +
                "Klasse|17|Buben 2013|4\n" +
                "Klasse|5|Mädchen 2012|5\n" +
                "Klasse|7|Buben 2012|6\n" +
                "Klasse|6|Mädchen 2011|7\n" +
                "Klasse|8|Buben 2011|8\n" +
                "Klasse|9|Mädchen 2010|9\n" +
                "Klasse|11|Buben 2010|10\n" +
                "Klasse|10|Mädchen 2009|11\n" +
                "Klasse|12|Buben 2009|12"
                , classes);


            string groups = cl.getGroups();

            Assert.AreEqual(
                "Gruppe|9|Bambini weiblich|1\n" +
                "Gruppe|2|Bambini männlich|2\n" +
                "Gruppe|3|U8 weiblich|3\n" +
                "Gruppe|4|U8 männlich|4\n" +
                "Gruppe|5|U10 weiblich|5\n" +
                "Gruppe|6|U10 männlich|6"
                , groups);

            string categories = cl.getCategories();

            Assert.AreEqual("Kategorie|M|M|1\nKategorie|W|W|2", categories);

            string participants = cl.getParticipantsData();

            Assert.AreEqual(
                "W|5|10|1|1||Nachname 1, Vorname 1|2009|Nation 1|Verein 1|9999,99\nM|2|17|2|2||Nachname 2, Vorname 2|2013|Nation 2|Verein 2|9999,99\nM|4|8|3|3||Nachname 3, Vorname 3|2011|Nation 3|Verein 3|9999,99\nW|9|20|4|4||Nachname 4, Vorname 4|2014|Nation 4|Verein 4|9999,99\nM|4|7|5|5||Nachname 5, Vorname 5|2012|Nation 5|Verein 5|9999,99"
                , participants);
            string startList = cl.getStartListData(model.GetCurrentRaceRun());

            Assert.AreEqual(
                "  4\n  2\n  5\n  3\n  1",
                startList);

            string timingData = cl.getTimingData(model.GetCurrentRaceRun());

            Assert.AreEqual("  10000010,23\n  29000000,01\n  31999999,99\n  42999999,99\n  53999999,99", timingData);
        }