public void isWinCorrectForWin()
        {
            // Arrange
            WordToGuess  wordToGuess = new WordToGuess();
            const string THE_WORD    = "dakota";

            wordToGuess.setWord(THE_WORD);
            Guess  guess         = new Guess();
            string guessedLetter = "d";

            guess.guessedLetter(guessedLetter, wordToGuess);
            string ignore = wordToGuess.getGuessesSoFar(guessedLetter);

            guessedLetter = "a";
            guess.guessedLetter(guessedLetter, wordToGuess);
            ignore        = wordToGuess.getGuessesSoFar(guessedLetter);
            guessedLetter = "k";
            guess.guessedLetter(guessedLetter, wordToGuess);
            ignore        = wordToGuess.getGuessesSoFar(guessedLetter);
            guessedLetter = "o";
            guess.guessedLetter(guessedLetter, wordToGuess);
            ignore        = wordToGuess.getGuessesSoFar(guessedLetter);
            guessedLetter = "t";
            guess.guessedLetter(guessedLetter, wordToGuess);
            ignore = wordToGuess.getGuessesSoFar(guessedLetter);

            // Act
            bool actualIsWin = wordToGuess.isWin();

            // Assert
            Assert.IsTrue(actualIsWin);
        }
示例#2
0
        public void isLetterInWordNo()
        {
            // Arrange
            WordToGuess  wordToGuess = new WordToGuess();
            const string THE_WORD    = "jellybean";

            wordToGuess.setWord(THE_WORD);

            // Act
            const string LETTER = "z";
            bool         actualIsLetterInWord = wordToGuess.isLetterInWord(LETTER);

            // Assert
            Assert.IsFalse(actualIsLetterInWord);
        }
        public void isLetterInWordYes()
        {
            // Arrange
            WordToGuess  wordToGuess = new WordToGuess();
            const string THE_WORD    = "dakota";

            wordToGuess.setWord(THE_WORD);

            // Act
            const string LETTER = "a";
            bool         actualIsLetterInWord = wordToGuess.isLetterInWord(LETTER);

            // Assert
            Assert.IsTrue(actualIsLetterInWord);
        }
示例#4
0
        public void getHiddenWordIsCorrect()
        {
            // Arrange
            WordToGuess  wordToGuess = new WordToGuess();
            const string THE_WORD    = "jellybean";

            wordToGuess.setWord(THE_WORD);

            // Act
            string actualHiddenWord = wordToGuess.getHiddenWord();

            // Assert
            const string EXPECTED_HIDDEN_WORD = "_ _ _ _ _ _ _ _ _ ";

            Assert.AreEqual(EXPECTED_HIDDEN_WORD, actualHiddenWord);
        }
示例#5
0
        public void GuessedLetterMostRecentLetterIsAccurate()
        {
            // Arrange
            Guess        guess       = new Guess();
            WordToGuess  wordToGuess = new WordToGuess();
            const string THE_WORD    = "jellybean";

            wordToGuess.setWord(THE_WORD);
            const string GUESSED_LETTER = "a";

            guess.guessedLetter(GUESSED_LETTER, wordToGuess);

            // Act
            string actualMostRecentLetter = guess.getMostRecentGuess();

            // Assert
            Assert.AreEqual(GUESSED_LETTER, actualMostRecentLetter);
        }
示例#6
0
        public void isWinCorrectForLoss()
        {
            // Arrange
            WordToGuess  wordToGuess = new WordToGuess();
            const string THE_WORD    = "jellybean";

            wordToGuess.setWord(THE_WORD);
            Guess  guess         = new Guess();
            string guessedLetter = "z";

            guess.guessedLetter(guessedLetter, wordToGuess);

            // Act
            bool actualIsWin = wordToGuess.isWin();

            // Assert
            Assert.IsFalse(actualIsWin);
        }
示例#7
0
        public void GuessedLetterCorrectLetterIsAccurate()
        {
            // Arrange
            Guess        guess       = new Guess();
            WordToGuess  wordToGuess = new WordToGuess();
            const string THE_WORD    = "jellybean";

            wordToGuess.setWord(THE_WORD);
            const string CORRECT_LETTER = "a";

            guess.guessedLetter(CORRECT_LETTER, wordToGuess);

            // Act
            int actualWrongGuessCount = guess.getWrongGuesses();

            // Assert
            const int EXPECTED_WRONG_GUESS_COUNT = 0;

            Assert.AreEqual(EXPECTED_WRONG_GUESS_COUNT, actualWrongGuessCount);
        }
示例#8
0
        public void getGuessedSoFarCorrect()
        {
            // Arrange
            WordToGuess  wordToGuess = new WordToGuess();
            const string THE_WORD    = "jellybean";

            wordToGuess.setWord(THE_WORD);
            Guess        guess          = new Guess();
            const string GUESSED_LETTER = "a";

            guess.guessedLetter(GUESSED_LETTER, wordToGuess);

            // Act
            string actualGuessSoFar = wordToGuess.getGuessesSoFar(GUESSED_LETTER);

            // Assert
            const string EXPECTED_GUESSED_SO_FAR = "_ _ _ _ _ _ _ a _ ";

            Assert.AreEqual(EXPECTED_GUESSED_SO_FAR, actualGuessSoFar);
        }
示例#9
0
        public void GetWrongGuessesIsAccurate()
        {
            // Arrange
            Guess        guess       = new Guess();
            WordToGuess  wordToGuess = new WordToGuess();
            const string THE_WORD    = "dakota";

            wordToGuess.setWord(THE_WORD);
            const string INCORRECT_LETTER = "z";

            guess.guessedLetter(INCORRECT_LETTER, wordToGuess);
            const string ANOTHER_INCORRECT_LETTER = "y";

            guess.guessedLetter(ANOTHER_INCORRECT_LETTER, wordToGuess);

            // Act
            int actualWrongGuessCount = guess.getWrongGuesses();

            // Assert
            const int EXPECTED_WRONG_GUESS_COUNT = 2;

            Assert.AreEqual(EXPECTED_WRONG_GUESS_COUNT, actualWrongGuessCount);
        }
示例#10
0
 public void setWord(string word)
 {
     wordToGuess.setWord(word);
 }