コード例 #1
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));
        }
コード例 #2
0
        private void StartNumbersUC_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (!(bool)e.OldValue && (bool)e.NewValue) // Became visible
            {
                _snaWorkspace.LoadFromRace(_race, true);

                UiUtilities.FillGrouping(cmbGrouping, _race.RaceConfiguration.Run1_StartistViewGrouping);
                txtNotToBeAssigned.Text = Properties.Settings.Default.StartNumbersNotToBeAssigned;

                SetupDefaults();

                OnWorkspaceChanged(this, null);
                OnCurrentGroupChangedHandler(this, null);
            }
        }
コード例 #3
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++;
            }
        }
コード例 #4
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);
        }
コード例 #5
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);
        }