public void GetHelpSummary_ReturnsDescription() { ArrangeInputs(parseResultSections: string.Empty, out MockedShellState shellState, out HttpState httpState, out ICoreParseResult _); SetBearerCommand setBearerCommand = new SetBearerCommand(); string result = setBearerCommand.GetHelpSummary(shellState, httpState); Assert.Equal(setBearerCommand.Description, result); }
public void CanHandle_WithSecondParseResultSectionNotEqualToSubCommand_ReturnsNull() { ArrangeInputs(parseResultSections: "set base token", out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult); SetBearerCommand setBearerCommand = new SetBearerCommand(); bool? result = setBearerCommand.CanHandle(shellState, httpState, parseResult); Assert.Null(result); }
public void CanHandle_WithValidInput_ReturnsTrue() { ArrangeInputs(parseResultSections: "set bearer token", out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult); SetBearerCommand setBearerCommand = new SetBearerCommand(); bool? result = setBearerCommand.CanHandle(shellState, httpState, parseResult); Assert.True(result); }
public void CanHandle_WithParseResultSectionsLessThanTwo_ReturnsNull() { ArrangeInputs(parseResultSections: "set", out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult); SetBearerCommand setBearerCommand = new SetBearerCommand(); bool? result = setBearerCommand.CanHandle(shellState, httpState, parseResult); Assert.Null(result); }
public async Task ExecuteAsync_WithMoreThanThreeValidParseResultSections_SetsThirdSectionAsToken() { ArrangeInputs(parseResultSections: "set bearer aSampleJwtToken token token2 token3", out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult); SetBearerCommand setBearerCommand = new SetBearerCommand(); await setBearerCommand.ExecuteAsync(shellState, httpState, parseResult, CancellationToken.None); Assert.Equal("aSampleJwtToken", httpState.BearerToken); }
public async Task ExecuteAsync_WithExactlyTwoValidParseResultSections_DoesNotSetToken() { ArrangeInputs(parseResultSections: "set bearer", out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult); SetBearerCommand setBearerCommand = new SetBearerCommand(); await setBearerCommand.ExecuteAsync(shellState, httpState, parseResult, CancellationToken.None); Assert.Null(httpState.BearerToken); }
public void Suggest_WithNoParseResultSections_ReturnsName() { ArrangeInputs(parseResultSections: string.Empty, out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult); SetBearerCommand setBearerCommand = new SetBearerCommand(); IEnumerable <string> suggestions = setBearerCommand.Suggest(shellState, httpState, parseResult); Assert.Single(suggestions); Assert.Equal("set", suggestions.First()); }
public void Suggest_WithMoreThanOneParseResultSectionAndSelectedSectionGreaterThanZero_ReturnsName() { ArrangeInputs(parseResultSections: "set bearer", out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult, caretPosition: 10); SetBearerCommand setBearerCommand = new SetBearerCommand(); IEnumerable <string> suggestions = setBearerCommand.Suggest(shellState, httpState, parseResult); Assert.Single(suggestions); Assert.Equal("bearer", suggestions.First()); }
public void GetHelpDetails_ReturnsHelpDetails() { ArrangeInputs(parseResultSections: "set bearer", out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult); string expected = "\u001b[1mUsage: \u001b[39mset bearer [token]" + Environment.NewLine + Environment.NewLine + "Sets or clears the bearer authorization header. When [token] is empty the bearer authorization is cleared." + Environment.NewLine; SetBearerCommand setBearerCommand = new SetBearerCommand(); string result = setBearerCommand.GetHelpDetails(shellState, httpState, parseResult); Assert.Equal(expected, result); }