Skip to content

Commit 50b7a21

Browse files
committed
check the command alias
1 parent 84d47b0 commit 50b7a21

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
executor: dotnet
1212
steps:
1313
- checkout
14-
- run: dotnet build -c Debug -p:Version=1.0.0
14+
- run: dotnet build -c Debug
1515
- run: dotnet test -c Debug --no-build
1616
build-push:
1717
executor: dotnet

tests/MicroBatchFramework.Tests/SubCommandTest.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,60 @@ public async Task TwoSubCommandTest()
8989
}
9090
}
9191

92+
public class AliasCommand : BatchBase
93+
{
94+
[Command(new[] { "run", "r" })]
95+
public void Run(string path, string pfx)
96+
{
97+
Context.Logger.LogInformation($"path:{path}");
98+
Context.Logger.LogInformation($"pfx:{pfx}");
99+
}
100+
101+
[Command(new[] { "su", "summmm" })]
102+
public void Sum([Option(0)]int x, [Option(1)]int y)
103+
{
104+
Context.Logger.LogInformation($"{x + y}");
105+
}
106+
}
107+
108+
[Fact]
109+
public async Task AliasCommandTest()
110+
{
111+
{
112+
var collection = new[]{
113+
"r -path foo -pfx bar".Split(' '),
114+
"run -path foo -pfx bar".Split(' '),
115+
};
116+
foreach (var args in collection)
117+
{
118+
var log = new LogStack();
119+
await new HostBuilder()
120+
.ConfigureTestLogging(testOutput, log, true)
121+
.RunBatchEngineAsync<AliasCommand>(args);
122+
log.InfoLogShouldBe(0, "path:foo");
123+
log.InfoLogShouldBe(1, "pfx:bar");
124+
}
125+
}
126+
{
127+
{
128+
var args = "su 10 20".Split(' ');
129+
var log = new LogStack();
130+
await new HostBuilder()
131+
.ConfigureTestLogging(testOutput, log, true)
132+
.RunBatchEngineAsync<AliasCommand>(args);
133+
log.InfoLogShouldBe(0, "30");
134+
}
135+
{
136+
var args = "summmm 99 100".Split(' ');
137+
var log = new LogStack();
138+
await new HostBuilder()
139+
.ConfigureTestLogging(testOutput, log, true)
140+
.RunBatchEngineAsync<AliasCommand>(args);
141+
log.InfoLogShouldBe(0, "199");
142+
}
143+
}
144+
}
145+
92146
public class NotFoundPath : BatchBase
93147
{
94148
[Command("run")]

0 commit comments

Comments
 (0)