public void VerifyThatPlayerResultIsSaved()
 {
     var highscore = new HighScore();
     var player = new Player("Pesho");
     player.Score = 1000;
     highscore.SaveHighScore(player);
     var output = highscore.ListHighScore();
     var isSaved = output.IndexOf("Pesho, Score: 1000");
     Assert.AreNotEqual(isSaved, -1);
 }
        public void VerifyThatHighScorePlayersAreListedCorrectly()
        {
            File.Delete(@"..\..\highscore.txt");
            var highscore = new HighScore();
            StringBuilder str = new StringBuilder();

            for (int i = 0; i < 5; i++)
            {
                var player = new Player("Pesho");
                player.Score = i;
                highscore.SaveHighScore(player);
                str.Append(string.Format("Rank {0}: {1}, Score: {2}\n", 5-i, player.Name, player.Score));
            }

            var output = highscore.ListHighScore();
            Assert.AreNotEqual(output, str);
        }
        public void VerifyThatLowScorePlayerIsNotRecorded()
        {
            var highscore = new HighScore();
            for (int i = 0; i < 5; i++)
            {
                var player = new Player("Pesho");
                player.Score = 1000;
                highscore.SaveHighScore(player);
            }

            var playerLow = new Player("Gosho");
            playerLow.Score = 10;
            highscore.SaveHighScore(playerLow);
            var output = highscore.ListHighScore();
            var isSaved = output.IndexOf("Gosho, Score: 10");

            Assert.AreEqual(isSaved, -1);
        }
Beispiel #4
0
 private void EnterPlayerName()
 {
     string inputPlayerName;
     do
     {
         this.renderer.DisplayMessage(Constants.INVITE_TO_ENTER_NAME_MESSAGE);
         inputPlayerName = this.renderer.EnterCommand();
     } while (!Validator.isValidPlayerName(inputPlayerName));
     this.currentPlayer = new Player(inputPlayerName);
 }