Skip to content

Commit

Permalink
Tyrrrz#13 - Add tests - suggest takes cursor positioning into account
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricel committed Mar 25, 2021
1 parent 8184f2d commit f57bcb4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions CliFx.Tests/SuggestDirectiveSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,24 @@ private string FormatExpectedOutput(string [] s)

[Theory]
[InlineData("supply all commands if nothing supplied",
"clifx.exe", new[] { "cmd", "cmd02" })]
"clifx.exe", 0, new[] { "cmd", "cmd02" })]
[InlineData("supply all commands that match partially",
"clifx.exe c", new[] { "cmd", "cmd02" })]
"clifx.exe c", 0, new[] { "cmd", "cmd02" })]
[InlineData("supply command options if match found, regardles of other partial matches (no options defined)",
"clifx.exe cmd", new string[] { })]
"clifx.exe cmd", 0, new string[] { })]
[InlineData("supply nothing if no partial match applies",
"clifx.exe cmd2", new string[] { })]
public async Task Suggest_directive_accepts_command_line_by_environment_variable(string usecase, string variableContents, string[] expected)
"clifx.exe cmd2", 0, new string[] { })]
[InlineData("supply all commands that match partially, allowing for cursor position",
"clifx.exe cmd", -2, new[] { "cmd", "cmd02" })]
public async Task Suggest_directive_suggests_commands_by_environment_variables(string usecase, string variableContents, int cursorOffset, string[] expected)
{
// Arrange
var application = TestApplicationFactory(_cmdCommandCs, _cmd2CommandCs)
.Build();

// Act
var exitCode = await application.RunAsync(
new[] { "[suggest]", "--envvar", "CLIFX-{GUID}", "--cursor", variableContents.Length.ToString() },
new[] { "[suggest]", "--envvar", "CLIFX-{GUID}", "--cursor", (variableContents.Length + cursorOffset).ToString() },
new Dictionary<string, string>()
{
["CLIFX-{GUID}"] = variableContents
Expand Down

0 comments on commit f57bcb4

Please sign in to comment.