Exemplo n.º 1
0
        public void TestSaveTournament()
        {
            List <ICompetitor> competitorList = new List <ICompetitor>
            {
                new Competitor("jkghjk", "Schwsadfsdfeer", "male", 1500, "local"),
                new Competitor("Chrisasdfsadtopher", "Heiasdfsdfd", "male", 1500, "local")
            };

            Tournament t = new Tournament("TURNIER_TESTfjlvdslvdslsdvlhsdhshdvlas", competitorList, 3, 12, new RankedSoloMatch(), false);

            t.StartTournament();
            List <Team> team = t.CurrentMatch.GetTeams();

            t.SetGoalForCurrentSet(team.ElementAt(0), 10, team.ElementAt(1), 8);

            ClientIMPL cdl = new ClientIMPL();

            if (cdl.FindClient("lhglhgljljlhlhbvhlhbkjhlj") != null)
            {
                cdl.AddClient("lhglhgljljlhlhbvhlhbkjhlj", "samwise", "Sam", "Gamdschie", "*****@*****.**", "männlich");
            }

            TMPersistenz.SaveFinishedTournamendToDB(t, "lhglhgljljlhlhbvhlhbkjhlj");

            Assert.AreEqual(t, (Tournament)TMPersistenz.GetTournamentFromDB("TURNIER_TESTfjlvdslvdslsdvlhsdhshdvlas", competitorList));

            //Lösche das Ranking und Tournament
            TMPersistenz.DeleteTournamentInDB("TURNIER_TESTfjlvdslvdslsdvlhsdhshdvlas");
        }
Exemplo n.º 2
0
        private void b_continue_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!tournament.IsFinished)
                {
                    tbl_chance_team1.Text = "Gewinnchance: \n" +
                                            (tournament.CurrentMatch.GetWinExpectationThatTeamAWins()).ToString() +
                                            " %";
                    tbl_chance_team2.Text = "Gewinnchance: \n" +
                                            (tournament.CurrentMatch.GetWinExpectationThatTeamBWins()).ToString() +
                                            " %";
                    tournament.SetGoalForCurrentSet(teams.ElementAt(0), Int32.Parse(tb_team1.Text), teams.ElementAt(1),
                                                    Int32.Parse(tb_team2.Text));
                    tb_team1.Clear();
                    tb_team2.Clear();

                    if (countSet == ApplicationState.GetValue <TournamentPers>("CurrentTournament").AmountSets)
                    {
                        countMatch++;
                        l_title.Content = "Spiel " + countMatch.ToString();
                        countSet        = 0;
                    }

                    teams = tournament.CurrentMatch.GetTeams();

                    if (!String.IsNullOrEmpty(tbl_team1.Text) && !String.IsNullOrEmpty(tbl_team2.Text))
                    {
                        tbl_team1.Text = teams.ElementAt(0).ToString();
                        tbl_team2.Text = teams.ElementAt(1).ToString();

                        countSet++;
                        tbl_nr_set.Text = "Satz: " + countSet.ToString();
                        ApplicationState.SetValue("MatchWinner", tournament.CurrentMatch.Winner);
                    }
                    else
                    {
                        MessageBox.Show("Bitte Tore eintragen", "KICKERCUP", MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                    }
                }

                if (tournament.IsFinished)
                {
                    TMPersistenz.SaveFinishedTournamendToDB(tournament,
                                                            ApplicationState.GetValue <Client>("LoggedOnUser").Username);

                    if (tournament.IsRanked)
                    {
                        //Rankings des Turniers in der Datenbank abspeichern
                        TMPersistenz.SaveRankingsToDB(tournament);
                    }

                    Finished_Tournament ft = new Finished_Tournament();
                    ft.DataChanged += Finished_Tournament_DataChanged;
                    ft.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }