Esempio n. 1
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);
        }
        private void btnAssignCurrentGroup_Click(object sender, RoutedEventArgs e)
        {
            setStartNumbersNotToAssign();
            setAnzVerlosung();

            try
            {
                _snaWorkspace.SetNextStartNumber(uint.Parse(txtNextStartNumber.Text));
                _rpSelector.AssignParticipants();
                _rpSelector.SwitchToNextGroup();
            }
            catch (Exception)
            { }
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public void StartNumberAssignment_ErrorCase_UnassignedClass()
        {
            TestDataGenerator tg = new TestDataGenerator();

            tg.createCatsClassesGroups();

            var participants = tg.Model.GetRace(0).GetParticipants();

            tg.createRaceParticipant();
            tg.createRaceParticipant(cat: tg.findCat('M'), cla: tg.findClass("2M (2010)"));
            tg.createRaceParticipant(cat: tg.findCat('W'), cla: tg.findClass("2W (2010)"));

            StartNumberAssignment sna = new StartNumberAssignment();
            ParticipantSelector   ps  = new ParticipantSelector(participants[0].Race, sna, null);

            Assert.IsTrue(ps.SwitchToFirstGroup());
            Assert.AreEqual("", ps.CurrentGroup);
            Assert.IsFalse(ps.SwitchToNextGroup());

            ps.GroupProperty = "Participant.Class";
            Assert.IsTrue(ps.SwitchToFirstGroup());
            Assert.AreEqual(tg.findClass("2M (2010)"), ps.CurrentGroup);
            Assert.IsTrue(ps.SwitchToNextGroup());
            Assert.AreEqual(tg.findClass("2W (2010)"), ps.CurrentGroup);
            Assert.IsTrue(ps.SwitchToNextGroup());
            Assert.AreEqual("", ps.CurrentGroup);
            Assert.IsFalse(ps.SwitchToNextGroup());

            ps.GroupProperty = "Group";
            Assert.IsTrue(ps.SwitchToFirstGroup());
            Assert.AreEqual(tg.findGroup("2M"), ps.CurrentGroup);
            Assert.IsTrue(ps.SwitchToNextGroup());
            Assert.AreEqual(tg.findGroup("2W"), ps.CurrentGroup);
            Assert.IsTrue(ps.SwitchToNextGroup());
            Assert.AreEqual("", ps.CurrentGroup);
            Assert.IsFalse(ps.SwitchToNextGroup());
        }