コード例 #1
0
        public void PlayerProxyConstructorAndPropertriesGetterAndSetterWorksProper()
        {
            string expectedNickName = "Pesho";
            int expectedScore = 15;

            PlayerProxy proxy = new PlayerProxy(expectedNickName, expectedScore);

            Assert.AreEqual(expectedNickName, proxy.Nickname, "Expected and actual PlayerProxy Nickname are not equal");
            Assert.AreEqual(expectedScore, proxy.Score, "Expected and actual PlayerProxy Score are not equal");
        }
コード例 #2
0
        /// <summary>
        /// Method to add you score to the highscore table
        /// </summary>
        private void EnterScoreRecordHandler()
        {
            Console.Write("Enter your nickname: ");

            var nickname = Console.ReadLine();

            try
            {
                var playerProxy = new PlayerProxy(nickname, this.Player.Score);
                var scoresHandler = new ScoresHandler();
                scoresHandler.LoadFromFile(GlobalErrorMessages.SaveRecordstFileName);
                scoresHandler.AddReccord(playerProxy);
                scoresHandler.SaveToFile(GlobalErrorMessages.SaveRecordstFileName);
                Console.WriteLine("Press any key to continiue..");
                Console.ReadKey();
                MainMenu.PrintMenu(this.engine);
            }
            catch (ArgumentOutOfRangeException)
            {
                Console.WriteLine("The name should be between 2 and 10 characters");
                this.EnterScoreRecordHandler();
            }
        }