Beispiel #1
0
        public void CanRemoveBracketRoundFromTournamentById()
        {
            List <Guid> roundIds = new List <Guid>();

            using (TournamentRepository tournamentRepository = CreateTournamentRepository())
            {
                Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName);

                RoundBase round = tournamentRepository.AddBracketRoundToTournament(tournament);
                roundIds.Add(round.Id);

                round = tournamentRepository.AddDualTournamentRoundToTournament(tournament);
                roundIds.Add(round.Id);

                round = tournamentRepository.AddRoundRobinRoundToTournament(tournament);
                roundIds.Add(round.Id);

                tournamentRepository.Save();
            }

            using (TournamentRepository tournamentRepository = CreateTournamentRepository())
            {
                Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName);

                foreach (Guid roundId in roundIds)
                {
                    bool removeResult = tournamentRepository.RemoveRoundFromTournament(tournament, roundId);
                    tournamentRepository.Save();

                    removeResult.Should().BeTrue();
                }

                tournament.Rounds.Should().BeEmpty();
            }
        }
Beispiel #2
0
        public void CanGetEmptyPlayerReferencesListFromTournament()
        {
            InitializeUsersAndBetters();

            using (TournamentRepository tournamentRepository = CreateTournamentRepository())
            {
                Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName);

                tournamentRepository.AddRoundRobinRoundToTournament(tournament);

                List <PlayerReference> playerReferences = tournamentRepository.GetPlayerReferencesByTournamentId(tournament.Id).ToList();

                playerReferences.Should().BeEmpty();
            }
        }
Beispiel #3
0
        public void CanChangePlayersPerGroupCountInRoundRobinRound()
        {
            using (TournamentRepository tournamentRepository = CreateTournamentRepository())
            {
                Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName);
                RoundBase  round      = tournamentRepository.AddRoundRobinRoundToTournament(tournament);

                const int newPlayersPerGroupCount      = 7;
                const int expectedPlayersPerGroupCount = newPlayersPerGroupCount;

                bool changeResult = tournamentRepository.SetPlayersPerGroupCountInRound(round, newPlayersPerGroupCount);

                changeResult.Should().BeTrue();
                round.PlayersPerGroupCount.Should().Be(expectedPlayersPerGroupCount);
            }
        }
        protected void InitializeRoundGroupAndPlayers()
        {
            using (TournamentRepository tournamentRepository = CreateTournamentRepository())
            {
                Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName);

                RoundRobinRound round = tournamentRepository.AddRoundRobinRoundToTournament(tournament);
                tournamentRepository.SetPlayersPerGroupCountInRound(round, playerNames.Count);

                foreach (string playerName in playerNames)
                {
                    tournamentRepository.AddPlayerReference(tournament, playerName);
                }

                tournamentRepository.Save();
            }
        }
Beispiel #5
0
        public void GivenTournamentAddsRounds(string tournamentName, Table table)
        {
            using (TournamentRepository tournamentRepository = CreateTournamentRepository())
            {
                Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName);

                foreach (TableRow row in table.Rows)
                {
                    TestUtilities.ParseRoundTable(row, out ContestTypeEnum contestType, out string name, out int advancingCount, out int playersPerGroupCount);

                    if (contestType != ContestTypeEnum.None)
                    {
                        RoundBase round = null;

                        if (contestType == ContestTypeEnum.Bracket)
                        {
                            round = tournamentRepository.AddBracketRoundToTournament(tournament);
                        }
                        else if (contestType == ContestTypeEnum.DualTournament)
                        {
                            round = tournamentRepository.AddDualTournamentRoundToTournament(tournament);
                        }
                        else if (contestType == ContestTypeEnum.RoundRobin)
                        {
                            round = tournamentRepository.AddRoundRobinRoundToTournament(tournament);
                        }
                        tournamentRepository.Save();

                        if (round == null)
                        {
                            return;
                        }

                        tournamentRepository.RenameRoundInTournament(round, name);
                        tournamentRepository.SetAdvancingPerGroupCountInRound(round, advancingCount);
                        tournamentRepository.SetPlayersPerGroupCountInRound(round, playersPerGroupCount);
                        tournamentRepository.Save();
                    }
                }
            }
        }
Beispiel #6
0
        public void CanAddRoundRobinRoundToTournament()
        {
            using (TournamentRepository tournamentRepository = CreateTournamentRepository())
            {
                Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName);
                tournament.Rounds.Should().BeEmpty();

                tournamentRepository.AddRoundRobinRoundToTournament(tournament);
                tournamentRepository.Save();

                tournament.Rounds.Should().HaveCount(1);
                tournament.Rounds.First().Should().BeOfType <RoundRobinRound>();
            }

            using (TournamentRepository tournamentRepository = CreateTournamentRepository())
            {
                Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName);
                tournament.Rounds.Should().HaveCount(1);
                tournament.Rounds.First().Should().BeOfType <RoundRobinRound>();
            }
        }