Skip to content

Commit 5959570

Browse files
committed
Add test
1 parent 42332ab commit 5959570

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/System.CommandLine.Tests/Help/HelpBuilderTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,34 @@ public void Usage_section_for_subcommand_shows_arguments_for_subcommand_and_pare
249249
_console.ToString().Should().Contain(expected);
250250
}
251251

252+
[Fact]
253+
public void Usage_section_for_subcommand_shows_arguments_for_subcommand_and_parent_command_not_optional()
254+
{
255+
var arg = new Argument<string[]>
256+
{
257+
Name = "shared-args",
258+
Arity = ArgumentArity.OneOrMore
259+
};
260+
261+
var inner = new Command("inner", "command help")
262+
{
263+
arg
264+
};
265+
_ = new Command("outer", "command help")
266+
{
267+
inner,
268+
arg
269+
};
270+
271+
_helpBuilder.Write(inner, _console);
272+
273+
var expected =
274+
$"Usage:{NewLine}" +
275+
$"{_indentation}outer <shared-args>... inner <shared-args>...";
276+
277+
_console.ToString().Should().Contain(expected);
278+
}
279+
252280
[Fact]
253281
public void Usage_section_does_not_show_additional_arguments_when_TreatUnmatchedTokensAsErrors_is_not_specified()
254282
{

0 commit comments

Comments
 (0)