Exemple #1
0
        public static void Run()
        {
            var emailInput = new Input("name", "What is your email?");

            var passwordInput = new PasswordInput("password", "What is the password?");

            var inquirer = new Inquirer(emailInput, passwordInput);

            inquirer.Ask();

            System.Console.WriteLine($@"Your email is {emailInput.Answer()}!");
            System.Console.WriteLine($@"Secret password: {passwordInput.Answer()}!");
            System.Console.ReadKey();
        }
Exemple #2
0
        public static void Run()
        {
            var options   = new string[] { "Option 1", "Option 2" };
            var listInput = new ListInput("option", "Which option?", options);
            var sureInput = new InputConfirmation("confirm", "Are you sure?");

            var inquirer = new Inquirer(listInput, sureInput);

            inquirer.Ask();

            var answer = listInput.Answer();

            Console.WriteLine($@"You have selected option: {answer} - {options[Int32.Parse(answer)-1]}");
            Console.WriteLine(sureInput.Answer() == "y" ? "And you are sure!" : "And you are not sure!");
            Console.ReadKey();
        }
Exemple #3
0
        public static void Run()
        {
            var numbersOnly = new RegexValidator("^[0-9]*$");
            var nameInput   = new Input("name", "What is your name?");
            var ageInput    = new Input("age", "What is your age?");

            ageInput.SetValid(numbersOnly);

            var passwordInput = new PasswordInput("password", "What is the password?");

            var inquirer = new Inquirer(nameInput, ageInput, passwordInput);

            inquirer.Ask();

            System.Console.WriteLine($@"Hello {nameInput.Answer()}! Your age is {ageInput.Answer()}");
            System.Console.WriteLine($@"Secret password: {passwordInput.Answer()}!");
            System.Console.ReadKey();
        }
Exemple #4
0
        public void ShouldAskQuestionsInOrder()
        {
            var calledInput1 = false;
            var calledInput2 = false;
            var input01      = Substitute.For <IPrompt>();
            var input02      = Substitute.For <IPrompt>();

            input01.When(x => x.Ask())
            .Do(x => calledInput1 = true);
            input02.When(x => x.Ask())
            .Do(x => { if (calledInput1)
                       {
                           calledInput2 = true;
                       }
                });


            var Inquirer = new Inquirer(input01, input02);

            Inquirer.Ask();

            calledInput2.Should().BeTrue();
        }