public void Given_InputFromPrompt_OnlyExposedInTokenTransformations() { new AppRunner <App>() .UseArgumentPrompter() .UseParseDirective() .Verify(new Scenario { When = { Args = "[parse:t] PromptSecure", OnPrompt = Respond.WithText("super-secret") }, Then = { Output = @"password (Text): command: PromptSecure arguments: password <Text> value: ***** inputs: [prompt] ***** default: token transformations: >>> from shell Directive: [parse:t] Argument : PromptSecure" } }); }
public void Given_InputFromPrompt_OnlyExposedInTokenTransformations() { new AppRunner <App>() .UsePrompting() .UseParseDirective() .Verify(new Scenario { When = { Args = "[parse:t] PromptSecure", OnPrompt = Respond.WithText("super-secret") }, Then = { Output = @"password (Text): command: PromptSecure arguments: password <Text> value: ***** inputs: [prompt] ***** default: token transformations: >>> from shell Directive: [parse:t] Value : PromptSecure >>> after: expand-clubbed-flags (no changes) >>> after: split-option-assignments (no changes) " } }); }
public void WhenInheritedOptionMissing_Prompts() { new AppRunner <HierApp>() .UsePrompting() .Verify(new Scenario { When = { Args = $" --intercept1 1 {nameof(HierApp.Do)}", OnPrompt = Respond.WithText("2", prompt => prompt.StartsWith("inherited1")) }, Then = { AssertContext = ctx => ctx.ParamValuesShouldBe <HierApp>(1, 2) } }); }
public void WhenInterceptorOptionMissing_Prompts() { new AppRunner <App>() .UseArgumentPrompter() .Verify(new Scenario { When = { Args = $"{nameof(App.Do)} --inherited1 2", OnPrompt = Respond.WithText("1", prompt => prompt.StartsWith("intercept1")) }, Then = { AssertContext = ctx => ctx.ParamValuesShouldBe <App>(1, 2) } }); }
public void WhenOperandMissing_PromptsOnlyForOperand() { new AppRunner <App>() .UseArgumentPrompter() .Verify(new Scenario { When = { Args = $"{nameof(App.Do)} --opt1 simple", OnPrompt = Respond.WithText("something", prompt => prompt.StartsWith("arg1")) }, Then = { AssertContext = ctx => ctx.ParamValuesShouldBe("simple", "something"), Output = @"arg1 (Text): something" } }); }
public void WhenBoolOperandMissing_Prompts() { new AppRunner <App>() .UseArgumentPrompter() .Verify(new Scenario { When = { Args = $"{nameof(App.Bool)}", OnPrompt = Respond.WithText("true", prompt => prompt.StartsWith("operand1")) }, Then = { AssertContext = ctx => ctx.ParamValuesShouldBe(true), Output = @"operand1 (Boolean): true" } }); }
public void InjectedPrompterCanPromptForValues() { new AppRunner <App>() .UsePrompter() .Verify(new Scenario { When = { Args = "Do", OnPrompt = Respond.WithText("who's there") }, Then = { Output = @"knock knock: who's there who's there" } }); }
public void CanOverridePromptText() { new AppRunner <App>() .UseArgumentPrompter((c, p) => new ArgumentPrompter(p, (ctx, a) => "lala")) .Verify(new Scenario { When = { Args = $"{nameof(App.Do)}", OnPrompt = Respond.WithText("fishies", reuse: true) }, Then = { AssertContext = ctx => ctx.ParamValuesShouldBe("fishies", "fishies"), Output = @"lala (Text): fishies lala (Text): fishies" } }); }
public void WhenOptionMissing_PromptsOnlyForOption() { new AppRunner <App>() .UsePrompting() .Verify(new Scenario { When = { Args = $"{nameof(App.Do)} something", OnPrompt = Respond.WithText("simple", prompt => prompt.StartsWith("opt1")) }, Then = { AssertContext = ctx => ctx.ParamValuesShouldBe("simple", "something"), Output = @"opt1 (Text): simple " } }); }
public void CanFilterListOfArgumentsForPrompting() { new AppRunner <App>() .UsePrompting(argumentFilter: arg => arg.Name == "arg1") .Verify(new Scenario { When = { Args = $"{nameof(App.Do)}", OnPrompt = Respond.WithText("something", prompt => prompt.StartsWith("arg1")) }, Then = { AssertContext = ctx => ctx.ParamValuesShouldBe(null, "something"), Output = @"arg1 (Text): something " } }); }
public void BackspaceRemovesCharactersButNotPrompt() { new AppRunner <App>() .UseArgumentPrompter() .Verify(new Scenario { When = { Args = $"{nameof(App.Do)}", OnPrompt = Respond.WithText("yes\b\b\b\bno\b\b\bmaybe", reuse: true) }, Then = { AssertContext = ctx => ctx.ParamValuesShouldBe("maybe", "maybe"), Output = @"arg1 (Text): maybe opt1 (Text): maybe" } }); }
public void WhenOperandListProvided_DoesNotPrompt() { new AppRunner <App>() .UseArgumentPrompter() .Verify(new Scenario { When = { Args = $"{nameof(App.DoList)} something simple", OnPrompt = Respond.WithText("yes") }, Then = { AssertContext = ctx => ctx.ParamValuesShouldBe(new List <string> { "something", "simple" }), Output = "" } }); }