public void TopIsValidCommand()
        {
            CommandParser commandParser = new CommandParser();
            var actual = commandParser.ParseCommand("top");

            Assert.AreEqual("top",actual);
        }
        public void RestartIsValidCommand()
        {
            CommandParser commandParser = new CommandParser();
            var actual = commandParser.ParseCommand("restart");

            Assert.AreEqual("restart", actual);
        }
        public void LongerThanFourDigitNumberIsNotValid()
        {
            CommandParser commandParser = new CommandParser();
            var actual = commandParser.ParseCommand("19872");

            Assert.AreEqual("invalid command", actual);
        }
        public void FourDigitNumberIsValidCommand()
        {
            CommandParser commandParser = new CommandParser();
            var actual = commandParser.ParseCommand("1289");

            Assert.AreEqual("1289", actual);
        }
        public void EmptyStringIsNotValidCommand()
        {
            CommandParser commandParser = new CommandParser();
            var actual = commandParser.ParseCommand("");

            Assert.AreEqual("invalid command", actual);
        }
        public void CombinationOfDigitsAndLettersIsNotValidNumber()
        {
            CommandParser commandParser = new CommandParser();
            var actual = commandParser.ParseCommand("1a90");

            Assert.AreEqual("invalid number", actual);
        }
Exemple #7
0
        /// <summary>
        /// Entry point of the Engine. All High - level game logic methods are invoked in this methods to begin the game.
        /// </summary>
        public void Play()
        {
            this.Initialize();
            string command = null;
            CommandParser consoleReader = new CommandParser();
            UserInterface.PrintGameRulesMessage();

            while (!this.isGuessed)
            {
                Console.Write("Enter your guess or command: ");
                command = Console.ReadLine();
                command = consoleReader.ParseCommand(command);
                this.CommandExecution(command);
            }

            string nickName = this.ReadNickName();
            HallOfFame.AddPlayerToScoreboard(this.numberOfMoves, this.numberOfCheats, nickName);

            string scoreBoard = HallOfFame.GenerateScoreBoard();
            Console.WriteLine(scoreBoard);

            this.CreateNewGame();
        }