Ejemplo n.º 1
0
        /// <inheritdoc />
        public override bool AskConfirmation(string question, bool defaultValue = true)
        {
            var helperQuestion   = GetHelperQuestion();
            var questionInstance = new QuestionStrictConfirmation(question, defaultValue);

            return(helperQuestion.Ask(Input, Output, questionInstance) ?? defaultValue);
        }
        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));
        }