Beispiel #1
0
        public void PMDeletePlayerTest()
        {
            bool testDelete = false;

            // Test Parameters
            string deleteName = "Bunny",
                   testName = "Hugh",
                   testName2 = "Randall";
            List<int> tinkleScores = new List<int>() { 2, 6, 9, 90 };
            List<int> testScores = new List<int>() { 45, 87, 99 };
            List<int> testScores2 = new List<int>() { 5, 6, 7, 8 };

            Player deletePlayer = new Player(deleteName, false, 4, tinkleScores);
            Player testPlayer1 = new Player(testName, false, 3, testScores);
            Player testPlayer2 = new Player(testName2, false, 4, testScores2);

            PlayerManager testPlayMngr = new PlayerManager();

            // Add players to DB for
            testPlayMngr.SavePlayer(testPlayer1, testName);
            testPlayMngr.SavePlayer(deletePlayer, deleteName);
            testPlayMngr.SavePlayer(testPlayer2, testName2);

            // Delete testPlayer and test return value
            testDelete = testPlayMngr.DeletePlayerData(deleteName);

            Assert.IsTrue(testDelete);
        }
Beispiel #2
0
        private void DeletePlayerAction()
        {
            // Use PlayerManager to delete selected Player object
            // Use Manager to load player data

            // Retrieve session object if available
            if (Session["Player"] != null)
                GamePlayer = (Player)Session["Player"];

            PlayerManager playerManager = new PlayerManager();
            if ((this.PlayerNameTextBox.Text.Length > 0) && (GamePlayer != null))
            {
                if (GamePlayer.PlayerName == this.PlayerNameTextBox.Text)
                {
                    if (playerManager.DeletePlayerData(this.EnteredNameTextBox.Text))
                    {
                        // Clear Entered Text box
                        ClearForm();
                        this.FeedbackListBox.Items.Add(EnteredNameTextBox.Text + " deleted!");
                        this.EnteredNameTextBox.Text = "";
                        this.PlayerNameTextBox.Text = "";
                        Session.Remove("Player");
                    }
                }
                else
                {
                    this.FeedbackListBox.Items.Add("Loaded player mismatch!");
                }

            }
            else
                this.FeedbackListBox.Items.Add("Plaer not loaded, delete aborted"); ;
        }