예제 #1
0
        public void InititalDashedWordPrintTest()
        {
            IWord initialWord = new ProxyWord("initialWord");
            string expectedInitialWordView = "-----------";

            Assert.AreEqual(expectedInitialWordView, initialWord.Print());
        }
예제 #2
0
        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());
        }
예제 #3
0
        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());
        }
예제 #4
0
        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---");
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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);
        }
예제 #10
0
        /// <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;
        }