Пример #1
0
        public void CorrectAnswerFlow()
        {
            const string correctGuess = "WHITE CITY";

            using (var sw = new StringWriter())
                using (var sr = new StringReader($"{ChosenLine}\n{correctGuess}"))
                {
                    Console.SetOut(sw);
                    Console.SetIn(sr);

                    var ta = new TubeAnagrams(_tflApi);

                    var consoleOutput = sw.ToString().Split("\n");

                    Assert.Equal("What tube line do you want anagrams for?", consoleOutput[0]);
                    Assert.Equal($"Unscramble these anagrams of stops along the {ChosenLine} Line:", consoleOutput[1]);

                    var firstAnagram = consoleOutput[2];
                    Assert.True(IsAValidAnagram(firstAnagram, ResponseStations));

                    var answerResponse = consoleOutput[3];
                    Assert.Equal("Correct!", answerResponse);

//                var secondAnagram = consoleOutput[4];
//                Assert.True(TestHelpers.AreAnagrams("Shepherds Bush", secondAnagram));
                }
        }
Пример #2
0
        public void IncorrectAnswerFlow()
        {
            const string incorrectGuess = "XYZ";

            using (var sw = new StringWriter())
                using (var sr = new StringReader($"{ChosenLine}\n{incorrectGuess}"))
                {
                    Console.SetOut(sw);
                    Console.SetIn(sr);

                    var ta = new TubeAnagrams(_tflApi);

                    var consoleOutput = sw.ToString().Split("\n");

                    Assert.Equal("What tube line do you want anagrams for?", consoleOutput[0]);
                    Assert.Equal($"Unscramble these anagrams of stops along the {ChosenLine} Line:", consoleOutput[1]);

                    var anagram = consoleOutput[2];
                    Assert.True(IsAValidAnagram(anagram, ResponseStations));

                    var answerResponse = consoleOutput[3];
                    Assert.Equal($"No {incorrectGuess} is wrong.", answerResponse);
                }
        }