Skip to content

Commit 5d8a023

Browse files
committed
Test for inherited option ordering
1 parent db9c292 commit 5d8a023

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

Tests/CommandLineTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ public static void TestMore()
128128
== ClassifyJson.Serialize(CommandLineParser.Parse<Test2Cmd>(["del", "this"])));
129129
}
130130

131+
[Fact]
132+
public static void TestSubcommandIntermediate()
133+
{
134+
var c3 = CommandLineParser.Parse<Test3Cmd>(["sub", "base", "subbase", "item"]);
135+
Assert.IsType<Test3SubCmd>(c3.Cmd);
136+
var cs3 = (Test3SubCmd) c3.Cmd;
137+
Assert.Equal("base", cs3.Base);
138+
Assert.Equal("subbase", cs3.SubBase);
139+
Assert.Equal("item", cs3.ItemName);
140+
}
141+
131142
[Fact]
132143
public static void TestPostBuild()
133144
{
@@ -136,6 +147,7 @@ public static void TestPostBuild()
136147
CommandLineParser.PostBuildStep<CommandLineWithArray>(reporter);
137148
CommandLineParser.PostBuildStep<Test1Cmd>(reporter);
138149
CommandLineParser.PostBuildStep<Test2Cmd>(reporter);
150+
CommandLineParser.PostBuildStep<Test3Cmd>(reporter);
139151
}
140152

141153
class Reporter : IPostBuildReporter

Tests/Test3.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace RT.CommandLine.Tests;
2+
3+
class Test3Cmd
4+
{
5+
[IsPositional, IsMandatory]
6+
public Test3CmdBase Cmd;
7+
}
8+
9+
[CommandGroup]
10+
abstract class Test3CmdBase
11+
{
12+
[IsPositional, IsMandatory]
13+
public string Base;
14+
}
15+
16+
abstract class Test3CmdSubBase : Test3CmdBase
17+
{
18+
[IsPositional, IsMandatory]
19+
public string SubBase;
20+
}
21+
22+
[CommandName("sub")]
23+
sealed class Test3SubCmd : Test3CmdSubBase
24+
{
25+
[IsPositional, IsMandatory]
26+
public string ItemName;
27+
}

0 commit comments

Comments
 (0)