Exemple #1
0
        public void Tournament_BuildsRoundsSeeded()
        {
            var players = new List <Player>
            {
                new Player("A")
                {
                    Seed = 1
                },
                new Player("B")
                {
                    Seed = 2
                },
                new Player("C")
                {
                    Seed = 3
                },
                new Player("D")
                {
                    Seed = 4
                }
            };
            var tournament = new Tournament {
                Players = players
            };
            var swiss  = new Swiss();
            var rounds = swiss.BuildRounds(tournament, Enumerable.Empty <Round>(), tournament.RoundCount);

            rounds.Should().NotBeEmpty();
        }
Exemple #2
0
        public void Tournament_BuildsPlayoffs()
        {
            var tournament = new Tournament {
                Players = playoffPlayers
            };
            var swiss  = new Swiss();
            var rounds = swiss.BuildPlayoffRound(tournament, PlayoffRound.Playoff);

            rounds.Should().NotBeEmpty();
            rounds.SelectMany(x => x.Players).Count().Should().Be(16);

            var quarters = swiss.BuildPlayoffRound(tournament, PlayoffRound.QuarterFinal);

            quarters.Should().NotBeEmpty();
            quarters.SelectMany(x => x.Players).Count().Should().Be(8);

            var semis = swiss.BuildPlayoffRound(tournament, PlayoffRound.SemiFinal);

            semis.Should().NotBeEmpty();
            semis.SelectMany(x => x.Players).Count().Should().Be(4);

            var final = swiss.BuildPlayoffRound(tournament, PlayoffRound.Final);

            final.Should().NotBeEmpty();
            final.SelectMany(x => x.Players).Count().Should().Be(2);
        }
Exemple #3
0
        public void Standing_GetsPlayerRanking()
        {
            var players = new List <Player>
            {
                new Player("A"),
                new Player("B"),
                new Player("C"),
                new Player("D")
            };
            var tournament = new Tournament {
                Players = players
            };
            var swiss  = new Swiss();
            var rounds = swiss.BuildRounds(tournament, Enumerable.Empty <Round>(), tournament.RoundCount);

            rounds.Should().NotBeEmpty();
            tournament.Should().NotBeNull();
            foreach (var round in rounds)
            {
                foreach (var match in round.Matches)
                {
                    match.Winner = Winner.Player1;
                    match.Score();
                }
            }
            var standings = tournament.CurrentStandings();

            standings.Should().NotBeEmpty();
        }
Exemple #4
0
        public void Tournament_BuildsPlayoffs_WithCutoff()
        {
            var tournament = new Tournament {
                Players = playoffPlayers.Take(7).ToList()
            };
            var swiss  = new Swiss();
            var rounds = swiss.BuildPlayoffRound(tournament, PlayoffRound.Playoff);

            rounds.Should().NotBeEmpty();
            rounds.SelectMany(x => x.Players).Count().Should().Be(4);
        }
Exemple #5
0
        public void Tournament_BuildsMatches()
        {
            var players = new List <Player>
            {
                new Player("A"),
                new Player("B"),
                new Player("C"),
                new Player("D")
            };
            var tournament = new Tournament {
                Players = players
            };
            var swiss   = new Swiss();
            var matches = swiss.BuildMatchPairs(tournament.Players, tournament);

            matches.Should().NotBeEmpty();
            tournament.Should().NotBeNull();
        }