Exemple #1
0
 public void AlreadyIncorrectGuessDoesNotIncreaseCountOfIncorrectGuesses()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('z');
     game.Guess('z');
     Assert.IsTrue(game.guesses.Count == 1);
 }
Exemple #2
0
 public void GuessesUpdatedCorrectly()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('a');
     game.Guess('h');
     Assert.AreEqual(game.guessedWord, "ha---a-");
 }
Exemple #3
0
 public void gameWonReturnedAsTrueWhenWordIsCorrectlyGuessed()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('h');
     game.Guess('a');
     game.Guess('n');
     game.Guess('g');
     game.Guess('m');
     Assert.IsTrue(game.gameWon);
 }
Exemple #4
0
 public void gameOverFlagReturnedAsFalseWhenGameIsWon()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('h');
     game.Guess('a');
     game.Guess('n');
     game.Guess('g');
     game.Guess('m');
     Assert.IsTrue(game.gameOver);
 }
Exemple #5
0
        public HangmanGame()
        {
            gameParts = new HangmanParts("hangman", 6);
            while (!gameParts.gameOver)
            {
                FormattedGameStatus();
                if (gameParts.gameOver)
                {
                    break;
                }

                // get the user guess
                Console.WriteLine("Enter a press");
                char key = Console.ReadKey(true).KeyChar;
                if (Char.IsLetter(key))
                {
                    gameParts.Guess(key);
                }
            }
            Console.WriteLine("Game Over");
            Console.WriteLine("You " + (gameParts.gameWon ? "Won" : "Lost"));
            Console.WriteLine("The word was " + gameParts.wordToGuess);
        }
Exemple #6
0
 public void CaseOfGuessIgnorned()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('H');
     Assert.AreEqual(game.guessedWord, "h------");
 }
Exemple #7
0
 public void CorrectGuessNotAddedToListOfIncorrectGuesses()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('h');
     Assert.IsTrue(game.guesses.Count == 0);
 }
Exemple #8
0
 public void CorrectGuessAddedToGuessWord()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('h');
     Assert.AreEqual(game.guessedWord, "h------");
 }
Exemple #9
0
 public void IncorrectGussesIncreasesIncorrectGuessCounterByOne()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('z');
     Assert.IsTrue(game.guesses.Count == 1);
 }
Exemple #10
0
 public void IncorrectGussesAddedToListOfIncorrectGuesses()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('z');
     Assert.IsTrue(game.guesses.Contains('z'));
 }
Exemple #11
0
 public void gameOverFlagReturnedAsTrueWhenNumIncorrectGuessReachesMax()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 1);
     game.Guess('z');
     Assert.IsTrue(game.gameOver);
 }
Exemple #12
0
 public void gameOverFlagReturnedAsFalseWhenNumIncorrectGuessIsLessThanMax()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('z');
     Assert.IsFalse(game.gameOver);
 }
Exemple #13
0
 public void RepeatingGuessedLettersAreAddedAtCorrectPlaces()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('a');
     Assert.AreEqual(game.guessedWord, "-a---a-");
 }
Exemple #14
0
 public void CorrectGuessAtCorrectPlace()
 {
     Hangman.HangmanParts game = new Hangman.HangmanParts("hangman", 6);
     game.Guess('m');
     Assert.AreEqual(game.guessedWord, "----m--");
 }