public void WhenOperandMissing_PromptsOnlyForOperand()
 {
     new AppRunner <App>()
     .UsePrompting()
     .VerifyScenario(_testOutputHelper, new Scenario
     {
         Given    = { OnPrompt = Respond.With("something", prompt => prompt.StartsWith("arg1")) },
         WhenArgs = $"{nameof(App.Do)} --opt1 simple",
         Then     =
         {
             Outputs              = { new App.DoResult
                                      {
                                          Arg1 = "something",
                                          Opt1 = "simple"
                                      } },
             Result               = "arg1 (Text): something"
         }
     });
 }
Exemple #2
0
 public void WhenExplicitBoolOptionMissing_Prompts()
 {
     new AppRunner <App>(new AppSettings {
         Arguments = { BooleanMode = BooleanMode.Explicit }
     })
     .UseArgumentPrompter()
     .Verify(new Scenario
     {
         When =
         {
             Args     = $"{nameof(App.Flags)}",
             OnPrompt = Respond.With(
                 new Answer("true", prompt => prompt.StartsWith("a ")),
                 new Answer("false", prompt => prompt.StartsWith("b "))
                 )
         },
         Then = { AssertContext = ctx => ctx.ParamValuesShouldBe(true, false) }
     });
 }
        public void WhenPasswordMissing_BackspaceDoesNotRemovePromptText()
        {
            new AppRunner <App>()
            .UsePrompting()
            .VerifyScenario(_testOutputHelper, new Scenario
            {
                Given = { OnPrompt = Respond.With(
                              new Answer("lala", prompt => prompt.StartsWith("user")),
                              new Answer("fishies\b\b\b\b\b\b\bnew", prompt => prompt.StartsWith("password"))) },
                WhenArgs = $"{nameof(App.Secure)}",
                Then     =
                {
                    Outputs              = { new App.SecureResult {
                                                 User = "******", Password = new Password("new")
                                             } },
                    Result               = @"user (Text): lala
password (Text): "
                }
            });
        }
        public void WhenPasswordMissing_PromptMasksInput()
        {
            new AppRunner <App>()
            .UseArgumentPrompter()
            .Verify(new Scenario
            {
                When =
                {
                    Args     = $"{nameof(App.Secure)}",
                    OnPrompt = Respond.With(
                        new Answer("lala", prompt => prompt.StartsWith("user")),
                        new Answer("fishies", prompt => prompt.StartsWith("password")))
                },
                Then =
                {
                    AssertContext = ctx => ctx.ParamValuesShouldBe("lala", new Password("fishies")),
                    Output        = @"user (Text): lala
password (Text):"
                }
            });
        }
        public void DoubleEscape_ExitsPrompt()
        {
            new AppRunner <App>()
            .UsePrompting()
            .Verify(new Scenario
            {
                When =
                {
                    Args     = $"{nameof(App.Do)}",
                    OnPrompt = Respond.With(
                        new Answer("take1".ToConsoleKeyInfos().AppendEscapeKey().AppendEscapeKey(), prompt => prompt.StartsWith("arg1")),
                        new TextAnswer("not-used", prompt => prompt.StartsWith("arg1")))
                },
                Then =
                {
                    Output = @"arg1 (Text): 
opt1 (Text): 
"
                }
            });
        }
Exemple #6
0
        public void WhenOptionAndOperandMissing_PromptsForBoth()
        {
            new AppRunner <App>()
            .UseArgumentPrompter()
            .Verify(new Scenario
            {
                When =
                {
                    Args     = $"{nameof(App.Do)}",
                    OnPrompt = Respond.With(
                        new Answer("something", prompt => prompt.StartsWith("arg1")),
                        new Answer("simple", prompt => prompt.StartsWith("opt1"))
                        )
                },
                Then =
                {
                    AssertContext = ctx => ctx.ParamValuesShouldBe("simple", "something"),
                    Output        = @"arg1 (Text): something
opt1 (Text): simple"
                }
            });
        }
        public void WhenPasswordMissing_BackspaceDoesNotRemovePromptText()
        {
            // \b is Console for Backspace

            new AppRunner <App>()
            .UseArgumentPrompter()
            .Verify(new Scenario
            {
                When =
                {
                    Args     = $"{nameof(App.Secure)}",
                    OnPrompt = Respond.With(
                        new Answer("lala", prompt => prompt.StartsWith("user")),
                        new Answer("fishies\b\b\b\b\b\b\bnew", prompt => prompt.StartsWith("password")))
                },
                Then =
                {
                    AssertContext = ctx => ctx.ParamValuesShouldBe("lala", new Password("new")),
                    Output        = @"user (Text): lala
password (Text):"
                }
            });
        }
Exemple #8
0
        public void SingleEscape_ClearsPrompt()
        {
            var arg1Answer = "take1".ToConsoleKeyInfos().AppendEscapeKey().Concat("take2".ToConsoleKeyInfos());

            new AppRunner <App>()
            .UseArgumentPrompter()
            .Verify(new Scenario
            {
                When =
                {
                    Args     = $"{nameof(App.Do)}",
                    OnPrompt = Respond.With(
                        new Answer(arg1Answer, prompt => prompt.StartsWith("arg1")),
                        new Answer("simple", prompt => prompt.StartsWith("opt1")))
                },
                Then =
                {
                    AssertContext = ctx => ctx.ParamValuesShouldBe("simple", "take2"),
                    Output        = @"arg1 (Text): take2
opt1 (Text): simple"
                }
            });
        }
Exemple #9
0
 public Respond Handle(TestMessage message)
 {
     _messageRecorder.Messages.Add(message);
     return(Respond.With(new TestResponse()).ToSender());
 }
Exemple #10
0
 public void assert_was_sent_back_to_sender_happy_path()
 {
     Respond.With(new Message1()).ToSender()
     .AssertWasSentBackToSender();
 }
Exemple #11
0
 public void respond_gets_the_message_on_the_new_envelope()
 {
     Respond.With(theMessage).CreateEnvelope(theOriginalEnvelope)
     .Message.ShouldBeTheSameAs(theMessage);
 }