Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the helper question test.
        /// </summary>
        /// <param name="question">The question.</param>
        /// <param name="options">The option with <see cref="AbstractTester"/>.</param>
        /// <returns>The user answer.</returns>
        public Mixture Ask(BaseQuestion question, params Mixture[] options)
        {
            var input = new InputArgs();

            if (options.TryGet("interactive", out Mixture exists))
            {
                input.SetInteractive(exists);
            }

            if (inputs != null && inputs.Length > 0)
            {
                input.SetInputStream(CreateStream(inputs));
            }

            Initialize(options);
            return(Helper.Ask(input, Output, question));
        }