public void InititalDashedWordPrintTest() { IWord initialWord = new ProxyWord("initialWord"); string expectedInitialWordView = "-----------"; Assert.AreEqual(expectedInitialWordView, initialWord.Print()); }
public void PartlyRevealedWordPrintTest() { IWord partlyRevealedWord = new ProxyWord("newWord"); partlyRevealedWord.RevealedCharacters[1] = true; partlyRevealedWord.RevealedCharacters[3] = true; string expectedInitialWordView = "-e-W---"; Assert.AreEqual(expectedInitialWordView, partlyRevealedWord.Print()); }
public void RevealedWordPrintTest() { IWord revealedWord = new ProxyWord("word"); revealedWord.RevealedCharacters[0] = true; revealedWord.RevealedCharacters[1] = true; revealedWord.RevealedCharacters[2] = true; revealedWord.RevealedCharacters[3] = true; string expectedInitialWordView = "word"; Assert.AreEqual(expectedInitialWordView, revealedWord.Print()); }
public void CheckWordPrintViewAfterProcessingTheHelpCommandTest() { Player player = Player.Instance; player.Name = "Milena"; player.AttemptsToGuess = 0; var checkManager = new CheckManager(player); IWord word = new ProxyWord("test"); checkManager.DefineCommands(word); checkManager.CheckCommand("Help", word); Assert.AreEqual(word.PrintView, "t---"); }
public void HelpCommandTestMiddleCharacter() { CommandManager testCommands = new CommandManager(); IWord word = new ProxyWord("wordtest"); ICommand helpCommand = new HelpCommand(word); word.PrintView = "wor-----"; string expectedResult = "word----"; testCommands.Proceed(helpCommand); Assert.AreEqual(expectedResult, word.PrintView); }
public void CheckWordPrintViewAfterProcessingWithCharWhichIsNotPartOfTheWordTest() { Player player = Player.Instance; player.Name = "Milena"; player.AttemptsToGuess = 5; var checkManager = new CheckManager(player); IWord word = new ProxyWord("test"); char guessedChar = 'r'; checkManager.CheckLetterAccordance(word, guessedChar); bool checkProcessedWordPrintView = word.PrintView == "----"; Assert.IsTrue(checkProcessedWordPrintView); }
public void CheckWhenTheGuessIsWrongIfThePlayerAttemptsToGuessAreIncreasedTest() { Player player = Player.Instance; player.Name = "Milena"; player.AttemptsToGuess = 0; var checkManager = new CheckManager(player); IWord word = new ProxyWord("test"); char guessedChar = 'r'; checkManager.CheckLetterAccordance(word, guessedChar); int expectedPlayerAttemptsToGuess = 1; Assert.AreEqual(expectedPlayerAttemptsToGuess, player.AttemptsToGuess); }
public void IsTheHasHelpUsedStateFalseWhenUsingHelpOptionTest() { Player player = Player.Instance; player.Name = "Milena"; player.AttemptsToGuess = 0; var checkManager = new CheckManager(player); IWord word = new ProxyWord("test"); checkManager.DefineCommands(word); checkManager.HasHelpUsed = true; using (var writer = new StringWriter()) { Console.SetOut(writer); checkManager.CheckCommand("Help", word); writer.Flush(); string result = writer.GetStringBuilder().ToString(); string expected = "You have already used your help option!\r\n" + "The secret word is:----\r\n"; Assert.AreEqual(expected, result); } }
public void IsTheHasHelpUsedStateTrueWhenUsingHelpOptionTest() { Player player = Player.Instance; player.Name = "Milena"; player.AttemptsToGuess = 0; var checkManager = new CheckManager(player); IWord word = new ProxyWord("test"); checkManager.DefineCommands(word); checkManager.CheckCommand("Help", word); Assert.IsTrue(checkManager.HasHelpUsed); }
/// <summary> /// Loads the secret word through the selected choice strategy. /// </summary> private IWord LoadSecretWord() { SecretWordManager wordsManager = new SecretWordManager(); wordsManager.LoadAllSecretWords(this.PathToSecretWordsDirectory); List<string> allWords = wordsManager.GetAllSecretWords(); IWord secretWord = new ProxyWord(this.ChoiceWord(this.ChoiceStrategy, allWords)); this.CheckManager.DefineCommands(secretWord); UIMessages.WelcomeMessage(MaxPlayerAttempts); return secretWord; }