|
5 | 5 | using System.CommandLine.Builder;
|
6 | 6 | using System.CommandLine.Invocation;
|
7 | 7 | using System.CommandLine.Parsing;
|
| 8 | +using System.CommandLine.Tests.Utility; |
8 | 9 | using System.IO;
|
9 | 10 | using FluentAssertions;
|
10 | 11 | using Xunit;
|
@@ -112,6 +113,36 @@ public void Command_Suggest_returns_available_subcommands_and_option_aliases_and
|
112 | 113 | .BeEquivalentTo("subcommand", "--option", "command-argument");
|
113 | 114 | }
|
114 | 115 |
|
| 116 | + [Fact] |
| 117 | + public void Command_Suggest_without_text_to_match_orders_alphabetically() |
| 118 | + { |
| 119 | + var command = new Command("command") |
| 120 | + { |
| 121 | + new Command("andmythirdsubcommand"), |
| 122 | + new Command("mysubcommand"), |
| 123 | + new Command("andmyothersubcommand"), |
| 124 | + }; |
| 125 | + |
| 126 | + var suggestions = command.GetSuggestions(); |
| 127 | + |
| 128 | + suggestions.Should().BeEquivalentSequenceTo("andmyothersubcommand", "andmythirdsubcommand", "mysubcommand"); |
| 129 | + } |
| 130 | + |
| 131 | + [Fact] |
| 132 | + public void Command_Suggest_with_text_to_match_orders_by_match_position_then_alphabetically() |
| 133 | + { |
| 134 | + var command = new Command("command") |
| 135 | + { |
| 136 | + new Command("andmythirdsubcommand"), |
| 137 | + new Command("mysubcommand"), |
| 138 | + new Command("andmyothersubcommand"), |
| 139 | + }; |
| 140 | + |
| 141 | + var suggestions = command.GetSuggestions("my"); |
| 142 | + |
| 143 | + suggestions.Should().BeEquivalentSequenceTo("mysubcommand", "andmyothersubcommand", "andmythirdsubcommand"); |
| 144 | + } |
| 145 | + |
115 | 146 | [Fact]
|
116 | 147 | public void When_an_option_has_a_default_value_it_will_still_be_suggested()
|
117 | 148 | {
|
|
0 commit comments