コード例 #1
0
 public void SetPlayerDetails(int playerID)
 {
     var tempPlayer = fileHandler.GetPlayer(playerID);
     player = tempPlayer.Clone();
     this.playerID = playerID;
     playerView.SetPlayerDetails(player);
 }
コード例 #2
0
ファイル: TeamSuper.cs プロジェクト: bdr27/cp3046-3047Project
 private void AddPlayerToTeam(int playerID, Player player)
 {
     if (!players.ContainsKey(playerID))
     {
         players.Add(playerID, player);
         modalTeam.ShowPlayers(players);
     }
 }
コード例 #3
0
 public void SetPlayerDetails(Player player)
 {
     lblAge.Content = player.GetAge();
     lblContact.Content = player.GetContact();
     lblFirstName.Content = player.GetFName();
     lblGuardian.Content = player.GetGuardian();
     lblLastName.Content = player.GetLName();
     txtBlMedical.Text = player.GetMedical();
 }
コード例 #4
0
        public void PlayerDetails()
        {
            string fName = "John";
            string lName = "Smith";
            int age = 15;
            string guardian = "Julie";
            string pContact = "40404040";
            string medical = "sickish";

            Player player = new Player(fName, lName, age, guardian, pContact, medical);
            Assert.AreEqual(string.Format("fname: {0}, lname: {1}, age: {2}, guardian: {3}, contact: {4}, medical: {5}, ID: {6}",
                fName, lName, age, guardian, pContact, medical, 0), player.Details());
        }
コード例 #5
0
        public void PlayerClone()
        {
            string fName = "John";
            string lName = "Smith";
            int age = 15;
            string guardian = "Julie";
            string pContact = "40404040";
            string medical = "sickish";

            var player = new Player(fName, lName, age, guardian, pContact, medical);
            var newPlayer = player.Clone();
            Assert.AreNotSame(newPlayer, player);
        }
コード例 #6
0
 public bool IsValidPlayer()
 {
     if (CheckRegex.IsValidAge(GetAge()))
     {
         int age = Int32.Parse(GetAge());
         player = new Player(GetFirstName(), GetLastName(), age, GetGuardian(), GetContact(), GetMedical());
         if (player.IsValidPlayer())
         {
             return true;
         }
     }
     return false;
 }
コード例 #7
0
 private void HandleBtnDone_Click(object sender, RoutedEventArgs e)
 {
     Debug.WriteLine("I confirm");
     if (modalPlayer.IsValidPlayer())
     {
         buttonAction = ButtonAction.DONE;
         player = modalPlayer.GetPlayer();
         modalPlayer.Close();
     }
     else
     {
         modalPlayer.DisplayError();
     }
 }
コード例 #8
0
 private void HandlerBtnEdit_Click(object sender, RoutedEventArgs e)
 {
     var playerEdit = new PlayerEdit();
     playerEdit.SetPlayerDetails(player);
     playerView.Hide();
     ModalDisplay.ShowModal(playerEdit, playerView);
     if (playerEdit.GetButtonAction().Equals(ButtonAction.DONE))
     {
         player = playerEdit.GetPlayer();
         player.SetP_ID(playerID);
         fileHandler.UpdatePlayer(player);
         playerView.SetPlayerDetails(player);
     }
     playerView.Show();
 }
コード例 #9
0
        public void MOCKFileHandlerAddPlayer()
        {
            var testHandler = new MOCKFileHandler();
            testHandler.LoadPlayers();
            var testHandlerPlayers = testHandler.GetPlayers();
            var testPlayers = TestPlayers();

            var newPlayer = new Player("Bob", "Dude", 12, "Mummy", "5552189", "Can't run");
            testHandler.InsertPlayer(newPlayer);
            testPlayers.Add(testPlayers.Count+1, newPlayer);
            foreach (var item in testPlayers)
            {
                Assert.AreEqual(item.Value.Details(), testHandlerPlayers[item.Key].Details());
            }
        }
コード例 #10
0
        public void MOCKFileHandlerEditPlayer()
        {
            var testHandler = new MOCKFileHandler();
            testHandler.LoadPlayers();
            var testHandlerPlayers = testHandler.GetPlayers();
            var testPlayers = TestPlayers();
            var editPlayer = new Player("bob", "smith", 10, "someone", "4545454", "Sickly");
            var playerEdited = 0;
            editPlayer.SetP_ID(playerEdited);
            testPlayers[playerEdited] = editPlayer;
            testHandler.UpdatePlayer(editPlayer);

            foreach (var item in testPlayers)
            {
                Assert.AreEqual(item.Value.Details(), testHandlerPlayers[item.Key].Details());
            }
        }
コード例 #11
0
        public void MOCKFileHandlerDeletePlayer()
        {
            var testHandler = new MOCKFileHandler();
            testHandler.LoadPlayers();
            var testHandlerPlayers = testHandler.GetPlayers();
            var testPlayers = TestPlayers();
            var DeletePlayer = new Player("john", "smith", 24, "", "40404040", "");
            var playerDeleted = 0;
            DeletePlayer.SetP_ID(playerDeleted);
            testPlayers.Remove(playerDeleted);
            testHandler.DeletePlayer(DeletePlayer.GetP_ID());

            foreach (var item in testPlayers)
            {
                Assert.AreEqual(item.Value.Details(), testHandlerPlayers[item.Key].Details());
            }
        }
コード例 #12
0
 public void MOCKFileHandlerDeleteTeamPlayer()
 {
     var teamID = 1;
     var playerID = 1;
     var testHandler = new MOCKFileHandler();
     testHandler.LoadPlayers();
     testHandler.LoadTeams();
     var testHandlerPlayers = testHandler.GetPlayers();
     var testPlayers = TestPlayers();
     var team = testHandler.GetTeam(teamID);
     team.SetTeamID(teamID);
     var player = testHandler.GetPlayer(1);
     var testPlayer = new Player("john", "smith", 24, "", "40404040", "");
     testPlayer.SetP_ID(playerID);
     Assert.AreEqual(player.Details(), testPlayer.Details());
     testHandler.DeleteTeamPlayer(team.GetTeamID(), playerID);
     Assert.AreEqual(0, testHandler.GetTeam(1).GetPlayerIDs().Count);
     team.RemovePlayer(player.GetP_ID());
     Assert.AreEqual(team.GetPlayerIDs(), testHandler.GetTeam(teamID).GetPlayerIDs());
 }
コード例 #13
0
 public void PlayerValuesAreValidNoContact()
 {
     Player player = new Player("John", "Smith", 15, "", "47761676", "");
     Assert.IsTrue(player.IsValidPlayer());
 }
コード例 #14
0
 public void SetPlayerDetails(Player editingPlayer)
 {
     tbAge.Text = editingPlayer.GetAge().ToString();
     tbContact.Text = editingPlayer.GetContact();
     tbFirstName.Text = editingPlayer.GetFName();
     tbGuardian.Text = editingPlayer.GetGuardian();
     tbLastName.Text = editingPlayer.GetLName();
     tbMedical.Text = editingPlayer.GetMedical();
 }
コード例 #15
0
 public void UpdatePlayer(Player editPlayer)
 {
     players[editPlayer.GetP_ID()] = editPlayer;
 }
コード例 #16
0
 public void InsertPlayer(Player newPlayer)
 {
     players.Add(playerCounter++, newPlayer);
 }
コード例 #17
0
 public void UpdatePlayer(Player editPlayer)
 {
     players[editPlayer.GetP_ID()] = editPlayer;
     var updatePlayer = SqlQueries.UpdatePlayer(editPlayer.GetP_ID(), editPlayer.GetFName(), editPlayer.GetLName(), editPlayer.GetAge(), editPlayer.GetGuardian(), editPlayer.GetContact(), editPlayer.GetMedical());
     var updatePlayerCommand = new SQLiteCommand(updatePlayer, dbConnection);
     updatePlayerCommand.ExecuteNonQuery();
 }
コード例 #18
0
 public void InsertPlayer(Player newPlayer)
 {
     newPlayer.SetP_ID(playerCounter);
     players.Add(playerCounter++, newPlayer);
     var insertPlayer = SqlQueries.InsertPlayer(newPlayer.GetP_ID(), newPlayer.GetFName(), newPlayer.GetLName(), newPlayer.GetAge(), newPlayer.GetGuardian(), newPlayer.GetContact(), newPlayer.GetMedical());
     var insertPlayerCommand = new SQLiteCommand(insertPlayer, dbConnection);
     insertPlayerCommand.ExecuteNonQuery();
 }
コード例 #19
0
 public void PlayerToString()
 {
     Player player = new Player("John", "Smith", 15, "Julie", "47761676", "");
     Assert.AreEqual("John Smith", player.ToString());
 }
コード例 #20
0
 public void SetPlayerDetails(Player editingPlayer)
 {
     modalPlayer.SetPlayerDetails(editingPlayer);
 }
コード例 #21
0
 public void PlayerValuesAreInvalidNumber()
 {
     Player player = new Player("John", "Sm1th", 15, "Julie", "477t1676", "");
     Assert.IsFalse(player.IsValidPlayer());
 }
コード例 #22
0
 public void PlayerValuesAreInvalidFirstName()
 {
     Player player = new Player("J0hn", "Smith", 15, "Julie", "47761676", "");
     Assert.IsFalse(player.IsValidPlayer());
 }