Exemplo n.º 1
0
        public void Add_Referee_Test()
        {
            //arrange
            string name    = "TestName";
            string surname = "TestSurname";
            int    id      = 98;

            //act
            Referee testReferee = new Referee()
            {
                Name = name, Surname = surname, ID = id
            };
            RefereeList testrefereeList = new RefereeList();

            testrefereeList.Add(testReferee);



            //assert
            Referee lookingReferee = testrefereeList.FindByID(id);

            Assert.AreEqual(name, lookingReferee.Name, "Incompatibility in Add Referee to List");
            Assert.AreEqual(surname, lookingReferee.Surname, "Incompatibility in Add Referee to List");
            Assert.AreEqual(id, lookingReferee.ID, "Incompatibility in Add Referee to List");
        }
Exemplo n.º 2
0
        public void Remove_Referee_Test()
        {
            //arrange
            string name    = "TestName";
            string surname = "Testsurname";
            int    id      = 98;

            //act
            Referee testReferee = new Referee()
            {
                Name = name, Surname = surname, ID = id
            };
            RefereeList testRefereeList = new RefereeList();

            testRefereeList.Add(testReferee);
            testRefereeList.Remove(id);



            //assert
            var check = testRefereeList.FindByID(id);

            Assert.AreEqual(null, check, "Incompatibility in Remove Player from list");
        }
Exemplo n.º 3
0
        private void Button_Click_AddTournament(object sender, RoutedEventArgs e)
        {
            string name = TourName.Text;

            RefereeList refereeList = new RefereeList();
            bool        AreTeamsValid;
            bool        AreRefereesValid;
            bool        IsTypeValid;
            TeamList    teamList = new TeamList();
            GameTypes   type;

            foreach (var item in RefereesToChoose.RefereesListBox.SelectedItems)
            {
                if (item is Referee referee)
                {
                    refereeList.Add(referee);
                }
            }

            foreach (var item in TeamsToChoose.TeamsListBox.SelectedItems)
            {
                if (item is Team team)
                {
                    teamList.Add(team);
                }
            }
            if (GameTypeComboBox.SelectedItem is GameTypes types)
            {
                type        = types;
                IsTypeValid = true;
            }
            else
            {
                ErrorWindow errorWindow = new ErrorWindow();
                errorWindow.ErrorContent.Text = "Choose Game Type";
                errorWindow.Show();
                return;
            }

            if (refereeList.Count > 0)
            {
                AreRefereesValid = true;
            }
            else
            {
                ErrorWindow errorWindow = new ErrorWindow();
                errorWindow.ErrorContent.Text = "Choose at least one Referee";
                errorWindow.Show();
                return;
            }
            if (teamList.Count >= 2)
            {
                AreTeamsValid = true;
            }
            else
            {
                ErrorWindow errorWindow = new ErrorWindow();
                errorWindow.ErrorContent.Text = "Choose at least two Teams";
                errorWindow.Show();
                return;
            }


            if (IsTypeValid && AreTeamsValid && AreRefereesValid)
            {
                Tournaments tournament = new Tournaments()
                {
                    TeamList = teamList, RefereeList = refereeList, GameTypes = type, Name = name, ID = -1
                };
                TournamentViewModel.Tournaments.Add(tournament);

                ErrorWindow errorWindow = new ErrorWindow()
                {
                    Width = 350
                };
                errorWindow.ErrorContent.Text = "Succesfully added Tourament";
                errorWindow.Show();
                ViewTournaments.TourListBox.Items.Refresh();
                NavigationService.Navigate(ViewTournaments);
            }
        }