public void GetTournamentRoundRanksTest()
        {
            var target = new KoSf5PfFiTRS(2, 2, 2);
            MatchStrategy matchStrategy = new NonRandomMs();
            var competitors = Helpers.CompetitorListHelper.GetStandardCompetitors(5);
            var competitorRanks = target.GenerateResult(matchStrategy, competitors);

            Assert.AreEqual(1, competitorRanks[competitors[0]]);
            Assert.AreEqual(2, competitorRanks[competitors[1]]);
            Assert.AreEqual(3, competitorRanks[competitors[2]]);
            Assert.AreEqual(4, competitorRanks[competitors[3]]);
            Assert.AreEqual(5, competitorRanks[competitors[4]]);
        }
        public void GenerateResultTest()
        {
            RrKo1TS target = new RrKo1TS(2, 2);
            int tournamentRunSequence = 1;
            MatchStrategy matchStrategy = new NonRandomMs();
            List<Competitor> competitors = Helpers.CompetitorListHelper.GetStandardCompetitors(8);
            CompetitorRanks ranks = target.GenerateResult(tournamentRunSequence, matchStrategy, competitors);

            int i = 1;
            foreach (KeyValuePair<Competitor, int> rank in ranks.OrderBy(x => x.Key.Name))
            {
                Assert.AreEqual(i++, rank.Value);
            }
        }
        public void GetTournamentRoundRanksTest()
        {
            KoSfFiTRS target = new KoSfFiTRS(2);

            MatchStrategy matchStrategy = new NonRandomMs();
            List<Competitor> competitors = Helpers.CompetitorListHelper.GetStandardCompetitors(8);

            CompetitorRanks ranks = target.GenerateResult(matchStrategy, competitors);

            Assert.AreEqual(1, ranks[competitors[0]]);
            Assert.AreEqual(2, ranks[competitors[1]]);
            Assert.AreEqual(3, ranks[competitors[2]]);
            Assert.AreEqual(3, ranks[competitors[3]]);
            Assert.AreEqual(5, ranks[competitors[4]]);
            Assert.AreEqual(5, ranks[competitors[5]]);
            Assert.AreEqual(5, ranks[competitors[6]]);
            Assert.AreEqual(5, ranks[competitors[7]]);
        }
        public void GetTournamentRoundRanksTest()
        {
            int winsToClinchSemifinalMatch = 2;
            int winsToClinchFinalsMatch = 3;
            int winsToClinchPetitMatch = 2;
            KoSfPfFiTRS_Accessor knockoutSemisFinalsPetitsTRS = new KoSfPfFiTRS_Accessor(winsToClinchSemifinalMatch, winsToClinchFinalsMatch, winsToClinchPetitMatch);

            MatchStrategy matchStrategy = new NonRandomMs();
            List<Competitor> competitors = new List<Competitor>();
            competitors.Add(new Competitor() { Name = "A", TheoreticalRating = 90 });
            competitors.Add(new Competitor() { Name = "B", TheoreticalRating = 80 });
            competitors.Add(new Competitor() { Name = "C", TheoreticalRating = 70 });
            competitors.Add(new Competitor() { Name = "D", TheoreticalRating = 60 });

            CompetitorRanks ranks = knockoutSemisFinalsPetitsTRS.GenerateResult(matchStrategy, competitors);

            Assert.AreEqual(1, ranks[competitors[0]]);
            Assert.AreEqual(2, ranks[competitors[1]]);
            Assert.AreEqual(3, ranks[competitors[2]]);
            Assert.AreEqual(4, ranks[competitors[3]]);
        }
        public void RunTest_RoundRobinThenQuarterfinals_NonRandomMatches()
        {
            var competitors = Helpers.CompetitorListHelper.GetStandardCompetitors(8);

            TournamentStrategy tournamentStrategy = new RrKoSfFiTS(2.0, 2);
            MatchStrategy matchStrategy = new NonRandomMs();

            var study = new Study(tournamentStrategy, matchStrategy, false);
            study.Run(competitors, _numberOfTournamentIterations);

            DisplayTestResults(tournamentStrategy, matchStrategy, study);

            Assert.AreEqual(1, competitors[0].TournamentRankMean);
            Assert.AreEqual(2, competitors[1].TournamentRankMean);
            Assert.AreEqual(3, competitors[2].TournamentRankMean);
            Assert.AreEqual(4, competitors[3].TournamentRankMean);
            Assert.AreEqual(5, competitors[4].TournamentRankMean);
            Assert.AreEqual(6, competitors[5].TournamentRankMean);
            Assert.AreEqual(7, competitors[6].TournamentRankMean);
            Assert.AreEqual(8, competitors[7].TournamentRankMean);
        }
        public void GenerateResultTest_MultipleRoundsNonRandomMatches()
        {
            var trs = new RrTRS(2.0);
            MatchStrategy matchStrategy = new NonRandomMs();
            var competitors = Helpers.CompetitorListHelper.GetStandardCompetitors(6);

            var ranks = trs.GenerateResult(matchStrategy, competitors);

            Assert.AreEqual(30, trs.Matches.Count);
        }
        public void GenerateResultTest_MultipleRoundsPartialRoundNonRandomMatches()
        {
            var trs = new RrTRS(2.5);
            MatchStrategy matchStrategy = new NonRandomMs();
            var competitors = Helpers.CompetitorListHelper.GetStandardCompetitors(6);

            var ranks = trs.GenerateResult(matchStrategy, competitors);

            Assert.AreEqual(36, trs.Matches.Count);

            Assert.AreEqual(1, ranks[competitors[0]]);
            Assert.AreEqual(2, ranks[competitors[1]]);
            Assert.AreEqual(3, ranks[competitors[2]]);
            Assert.AreEqual(4, ranks[competitors[3]]);
            Assert.AreEqual(5, ranks[competitors[4]]);
            Assert.AreEqual(6, ranks[competitors[5]]);
        }
        public void GenerateSingleRoundResultTest_PartialRoundRobin()
        {
            var target = new RrTRS_Accessor();
            MatchStrategy matchStrategy = new NonRandomMs();

            var competitors = Helpers.CompetitorListHelper.GetStandardCompetitors(6);

            const double FractionOfPartialRound = 0.8;
            List<Match> actual = target.GenerateSingleRoundResult(matchStrategy, competitors, FractionOfPartialRound);

            Assert.AreEqual(12, actual.Count);
        }
        public void RunTest_RrRrSf5KoFiPfTS()
        {
            var competitors = Helpers.CompetitorListHelper.GetStandardCompetitors(8);

            TournamentStrategy tournamentStrategy = new RrRrSf5KoFiPfTS(1.0, 1.0, 2, 2, 1.0);
            MatchStrategy matchStrategy = new NonRandomMs();

            var study = new Study(tournamentStrategy, matchStrategy, false);
            study.Run(competitors, _numberOfTournamentIterations);

            DisplayTestResults(tournamentStrategy, matchStrategy, study);
        }