public void AllMatchesInPreviousRoundsFinished()
        {
            bool matchesFinished = true;
            int  numberOfRounds  = currentTournament.GetNumberOfRounds();

            for (int round = 0; round < numberOfRounds - 1; round++)
            {
                Round currentRound = currentTournament.GetRound(round);
                if (currentRound.IsRoundFinished() == false)
                {
                    matchesFinished = false;
                }
            }
            Assert.AreEqual(true, matchesFinished);
        }
        public void ScheduleNewRound(string tournamentName, bool printNewMatches = true)
        {
            Tournament t             = tournamentRepo.GetTournament(tournamentName);
            int        numberOfRound = t.GetNumberOfRounds();

            if (numberOfRound == 0)
            {
                List <Team> teams = t.GetTeams();
            }
            else
            {
                Round lastRound       = t.GetRound(numberOfRound - 1);
                bool  isRoundFinished = lastRound.IsRoundFinished();

                if (isRoundFinished == true)
                {
                    List <Team> team = lastRound.GetWinningTeams();
                    if (team.Count >= 2)
                    {
                        var rnd = new Random();
                        rnd.NextDouble();
                        Dictionary <Team, double> RandomList = new Dictionary <Team, double>();

                        foreach (Team item in lastRound.GetWinningTeams())
                        {
                            RandomList.Add(item, rnd.NextDouble());
                        }
                        RandomList.OrderByDescending(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value);

                        Round newRound = new Round();
                        if (team.Count % 2 == 1)
                        {
                            int oldFreeRider = newRound.GetFreeRider();
                        }
                    }
                }
            }
        }
        public void ScheduleNewRound(string tournamentName, bool printNewMatches = true)
        {
            Tournament t             = tournamentRepo.GetTournament(tournamentName);
            int        numberOfRound = t.GetNumberOfRounds();

            if (numberOfRound == 0)
            {
                List <Team> teams = t.GetTeams();
            }
            else
            {
                Round lastRound       = t.GetRound(numberOfRound - 1);
                bool  isRoundFinished = lastRound.IsRoundFinished();

                if (isRoundFinished == true)
                {
                    List <Team> teams = lastRound.GetWinningTeams();
                    if (teams.Count >= 2)
                    {
                        var rnd = new Random();
                        rnd.NextDouble();
                        Dictionary <Team, double> RandomList = new Dictionary <Team, double>();

                        foreach (Team team in lastRound.GetWinningTeams())
                        {
                            RandomList.Add(team, rnd.NextDouble());
                        }
                        RandomList.OrderByDescending(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value);
                        List <Team> randomList = RandomList.Keys.ToList();

                        Round newRound = new Round();
                        if (teams.Count % 2 == 1)
                        {
                            Team newFreeRider = randomList.Min();
                            Team oldFreeRider = newRound.GetFreeRider();
                            do
                            {
                                newFreeRider = randomList.Min();

                                randomList.Remove(newFreeRider);
                            }while (oldFreeRider == newFreeRider);

                            newRound.NewFreeRider = newFreeRider;
                        }
                        int noMatches = teams.Count / 2;

                        for (int i = 1; i <= noMatches; i++)
                        {
                            Match match = new Match();
                            foreach (Team team in randomList)
                            {
                                Team first;
                                Team second;



                                first = team;
                                randomList.Remove(team);
                                second = team;
                                randomList.Remove(team);
                                match.FirstOpponent  = first;
                                match.SecondOpponent = second;
                                newRound.AddMatch(match);
                            }
                        }

                        t.addRound(newRound);

                        Console.WriteLine("Ny runde tilføjet");
                        Console.ReadKey();
                    }
                    else
                    {
                        t.SetStatusFinished(true);
                    }
                    Console.WriteLine("Turneringen er overstået");
                    Console.ReadKey();
                }
            }
        }