Ejemplo n.º 1
0
        public void TestNormalCompetition()
        {
            var eventInfo = new EventInfo {
                eventType = EventType.Individual, roundInfos = IndividualNormal()
            };
            var hillInfo = new HillInfo(123, 140, 5.5m, 6.66m, 4.2m, 0.79m);

            var competitorsCount    = 8;
            var orderedParticipants = GetMockParticipantsIndividual(competitorsCount);
            var resultsManager      = new ResultsManager(eventInfo, orderedParticipants, hillInfo);

            resultsManager.RoundInit();
            resultsManager.SubroundInit();

            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Bibs[0]).ToList(),
                                    Enumerable.Range(1, competitorsCount).Reverse().ToList()));
            Assert.IsTrue(ListEqual(resultsManager.StartList,
                                    Enumerable.Range(0, competitorsCount).Reverse().ToList()));

            RegisterJumps(resultsManager, Enumerable.Repeat(123m, competitorsCount));

            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              Enumerable.Range(0, competitorsCount).ToList()));

            resultsManager.SubroundFinish();
            resultsManager.RoundInit();
            resultsManager.SubroundInit();
            Assert.IsTrue(ListEqual(resultsManager.StartList,
                                    Enumerable.Range(0, competitorsCount).Reverse().ToList()));
        }
Ejemplo n.º 2
0
        public void TestKOCompetitionOdd()
        {
            var eventInfo = new EventInfo {
                eventType = EventType.Individual, roundInfos = IndividualKO()
            };
            var hillInfo = new HillInfo(123, 140, 5.5m, 6.66m, 4.2m, 0.79m);

            const int competitorsCount = 7, competitorsCount2 = 5;
            var       orderedParticipants = GetMockParticipantsIndividual(competitorsCount);
            var       resultsManager      = new ResultsManager(eventInfo, orderedParticipants, hillInfo);

            resultsManager.RoundInit();
            resultsManager.SubroundInit();

            // bibs & start list 1st round
            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Bibs[0]).ToList(),
                                    Enumerable.Range(1, competitorsCount).ToList()));
            Assert.IsTrue(ListEqual(resultsManager.StartList, new List <int> {
                4, 3, 5, 2, 6, 1, 0
            }));

            RegisterJumps(resultsManager, Enumerable.Repeat(123m, competitorsCount));

            // order 1st round
            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              Enumerable.Range(0, competitorsCount).ToList()));

            resultsManager.SubroundFinish();
            resultsManager.RoundFinish();
            resultsManager.RoundInit();
            resultsManager.SubroundInit();

            // bibs & start list 2nd round

            Assert.IsTrue(
                ListEqual(resultsManager.StartList, Enumerable.Range(0, competitorsCount2).Reverse().ToList()));
            Assert.IsTrue(ListEqual(resultsManager.StartList.Select(it => resultsManager.Results[it].Bibs[1]).ToList(),
                                    resultsManager.StartList.Select(it => resultsManager.Results[it].Bibs[0]).ToList()));
            RegisterJumps(resultsManager, Enumerable.Repeat(123m, competitorsCount2));

            // order 2nd round
            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount2).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              Enumerable.Range(0, competitorsCount2).ToList()));
        }
Ejemplo n.º 3
0
        public void TestTeamCompetition()
        {
            var eventInfo = new EventInfo {
                eventType = EventType.Team, roundInfos = TeamNormal()
            };
            var hillInfo = new HillInfo(123, 140, 5.5m, 6.66m, 4.2m, 0.79m);

            const int competitorsCount = 5, competitorsCount2 = 3;
            var       orderedParticipants = GetMockParticipantsTeam(competitorsCount);
            var       resultsManager      = new ResultsManager(eventInfo, orderedParticipants, hillInfo);

            resultsManager.RoundInit();
            resultsManager.SubroundInit();

            // bibs 1st round
            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Bibs[0]).ToList(),
                                    Enumerable.Range(1, competitorsCount).Reverse().ToList()));

            // 1st round 1st group
            Assert.IsTrue(ListEqual(resultsManager.StartList,
                                    Enumerable.Range(0, competitorsCount).Reverse().ToList()));
            RegisterJumps(resultsManager, Enumerable.Repeat(123m, competitorsCount));
            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              Enumerable.Range(0, competitorsCount).ToList()));
            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Rank).ToList(),
                                    new List <int> {
                1, 1, 1, 1, 1
            }));
            resultsManager.SubroundFinish();

            // 1st round 2nd group
            resultsManager.SubroundInit();
            Assert.IsTrue(ListEqual(resultsManager.StartList,
                                    Enumerable.Range(0, competitorsCount).Reverse().ToList()));
            RegisterJumps(resultsManager, new List <decimal> {
                123, 124, 125, 124, 123
            });
            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              new List <int> {
                2, 1, 3, 0, 4
            }));
            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Rank).ToList(),
                                    new List <int> {
                4, 2, 1, 2, 4
            }));
            resultsManager.SubroundFinish();

            // 1st round 3rd group
            resultsManager.SubroundInit();
            Assert.IsTrue(ListEqual(resultsManager.StartList,
                                    Enumerable.Range(0, competitorsCount).Reverse().ToList()));
            RegisterJumps(resultsManager, new List <decimal> {
                123, 124, 125, 126, 127
            });
            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              Enumerable.Range(0, competitorsCount).ToList()));
            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Rank).ToList(),
                                    new List <int> {
                1, 1, 1, 4, 5
            }));
            resultsManager.SubroundFinish();

            // start list 1st round 4th group
            resultsManager.SubroundInit();
            Assert.IsTrue(ListEqual(resultsManager.StartList,
                                    Enumerable.Range(0, competitorsCount).Reverse().ToList()));
            RegisterJumps(resultsManager, new List <decimal> {
                130, 123, 123, 124, 124
            });
            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              new List <int> {
                4, 0, 1, 2, 3
            }));
            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Rank).ToList(),
                                    new List <int> {
                2, 2, 4, 5, 1
            }));
            resultsManager.SubroundFinish();
            resultsManager.RoundFinish();
            resultsManager.RoundInit();
            resultsManager.SubroundInit();

            // bibs 2nd round
            Assert.IsTrue(resultsManager.StartList.Select(it => resultsManager.Results[it])
                          .Any(it => it.Bibs[0] == it.Bibs[1]));

            // 2nd round 1st group
            Assert.IsTrue(ListEqual(resultsManager.StartList, new List <int> {
                4, 1, 0
            }));
            RegisterJumps(resultsManager, Enumerable.Repeat(123m, competitorsCount2));
            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount2).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              new List <int> {
                4, 0, 1
            }));
            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Rank).ToList(),
                                    new List <int> {
                2, 2, 4, 5, 1
            }));
            resultsManager.SubroundFinish();

            // 2nd round 2nd group
            resultsManager.SubroundInit();
            Assert.IsTrue(ListEqual(resultsManager.StartList, new List <int> {
                4, 1, 0
            }));
            RegisterJumps(resultsManager, Enumerable.Repeat(123m, competitorsCount2));
            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount2).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              new List <int> {
                4, 0, 1
            }));
            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Rank).ToList(),
                                    new List <int> {
                2, 2, 4, 5, 1
            }));
            resultsManager.SubroundFinish();

            // 2nd round 3rd group
            resultsManager.SubroundInit();
            Assert.IsTrue(ListEqual(resultsManager.StartList, new List <int> {
                4, 1, 0
            }));
            RegisterJumps(resultsManager, new List <decimal> {
                129, 131, 129
            });
            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount2).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              new List <int> {
                1, 4, 0
            }));
            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Rank).ToList(),
                                    new List <int> {
                3, 1, 4, 5, 1
            }));
            resultsManager.SubroundFinish();

            // 2nd round 4th group
            resultsManager.SubroundInit();
            Assert.IsTrue(ListEqual(resultsManager.StartList, new List <int> {
                0, 4, 1
            }));
            RegisterJumps(resultsManager, new List <decimal> {
                135, 131, 131
            });
            Assert.IsTrue(ListEqual(
                              Enumerable.Range(0, competitorsCount2).Select(it => resultsManager.GetIdByRank(it)).ToList(),
                              new List <int> {
                0, 1, 4
            }));
            Assert.IsTrue(ListEqual(resultsManager.Results.Select(it => it.Rank).ToList(),
                                    new List <int> {
                1, 2, 4, 5, 2
            }));
        }