public void SetPlayerDetails(int playerID) { var tempPlayer = fileHandler.GetPlayer(playerID); player = tempPlayer.Clone(); this.playerID = playerID; playerView.SetPlayerDetails(player); }
private void AddPlayerToTeam(int playerID, Player player) { if (!players.ContainsKey(playerID)) { players.Add(playerID, player); modalTeam.ShowPlayers(players); } }
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(); }
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()); }
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); }
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; }
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(); } }
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(); }
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()); } }
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()); } }
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()); } }
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()); }
public void PlayerValuesAreValidNoContact() { Player player = new Player("John", "Smith", 15, "", "47761676", ""); Assert.IsTrue(player.IsValidPlayer()); }
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(); }
public void UpdatePlayer(Player editPlayer) { players[editPlayer.GetP_ID()] = editPlayer; }
public void InsertPlayer(Player newPlayer) { players.Add(playerCounter++, newPlayer); }
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(); }
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(); }
public void PlayerToString() { Player player = new Player("John", "Smith", 15, "Julie", "47761676", ""); Assert.AreEqual("John Smith", player.ToString()); }
public void SetPlayerDetails(Player editingPlayer) { modalPlayer.SetPlayerDetails(editingPlayer); }
public void PlayerValuesAreInvalidNumber() { Player player = new Player("John", "Sm1th", 15, "Julie", "477t1676", ""); Assert.IsFalse(player.IsValidPlayer()); }
public void PlayerValuesAreInvalidFirstName() { Player player = new Player("J0hn", "Smith", 15, "Julie", "47761676", ""); Assert.IsFalse(player.IsValidPlayer()); }