예제 #1
0
        public void TestTesterHelperQuestionDefaultValue()
        {
            var tester = new TesterHelperQuestion();

            tester.SetInputs(new[] { string.Empty });

            var question = new BaseQuestion("What's your name?", "What?");

            Assert.AreEqual("What?", (string)tester.Ask(question));
            Assert.AreEqual("What's your name?", tester.GetDisplay());
        }
예제 #2
0
        public void TestTesterHelperQuestion()
        {
            var tester = new TesterHelperQuestion();

            tester.SetInputs(new[] { "menghanyu" });

            var question = new BaseQuestion("What's your name?", "What?");

            Assert.AreEqual("menghanyu", (string)tester.Ask(question));
            Assert.AreEqual("What's your name?", tester.GetDisplay());
        }
        public void TestAskConfirmationWithCustomErrorMessage()
        {
            var tester = new TesterHelperQuestion();

            tester.SetInputs(new[] { "foo" });
            var question = new QuestionStrictConfirmation("Do you like French fries?", false,
                                                          "^ab$", "^cdefg$", "Please answer ab or cdefg.");

            question.SetMaxAttempts(1);
            tester.Ask(question);
        }
        public void TestAskConfirmation(string answer, bool expected, bool defaultValue)
        {
            var tester = new TesterHelperQuestion();

            tester.SetInputs(new[] { answer });

            var question = new QuestionStrictConfirmation("Do you like French fries?", defaultValue);

            question.SetMaxAttempts(1);

            Assert.AreEqual(expected, (bool)tester.Ask(question));
        }
        public void TestAskConfirmationBadAnswer(string answer)
        {
            var tester = new TesterHelperQuestion();

            tester.SetInputs(new[] { answer });

            var question = new QuestionStrictConfirmation("Do you like French fries?");

            question.SetMaxAttempts(1);

            tester.Ask(question);
        }
        public void TestAskConfirmationWithCustomTrueAndFalseAnswer()
        {
            var tester = new TesterHelperQuestion();

            tester.SetInputs(new[] { "ab" });
            var question = new QuestionStrictConfirmation("Do you like French fries?", false,
                                                          "^ab$", "^cdefg$");

            question.SetMaxAttempts(1);
            Assert.AreEqual(true, (bool)tester.Ask(question));

            tester.SetInputs(new[] { "cdefg" });
            Assert.AreEqual(false, (bool)tester.Ask(question));
        }