Skip to content

Commit 815cad8

Browse files
committed
unit test for array argument
1 parent 57240a5 commit 815cad8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/ConsoleAppFramework.Tests/Integration/SingleCommandTest.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,48 @@ public void NoOptions_NoArgs()
1818
console.Output.Should().Contain("HelloMyWorld");
1919
}
2020

21+
[Fact]
22+
public void IntArguments()
23+
{
24+
using var console = new CaptureConsoleOutput();
25+
26+
var args = "--foo 1,2,3".Split(' ');
27+
28+
ConsoleApp.RunAsync(args, (string[] foo) =>
29+
{
30+
foreach (var item in foo)
31+
{
32+
Console.WriteLine(item);
33+
}
34+
});
35+
36+
console.Output.Should().Be(@"1
37+
2
38+
3
39+
");
40+
}
41+
42+
[Fact]
43+
public void StringArguments()
44+
{
45+
using var console = new CaptureConsoleOutput();
46+
47+
var args = "--foo a,b,c".Split(' ');
48+
49+
ConsoleApp.RunAsync(args, (string[] foo) =>
50+
{
51+
foreach (var item in foo)
52+
{
53+
Console.WriteLine(item);
54+
}
55+
});
56+
57+
console.Output.Should().Be(@"a
58+
b
59+
c
60+
");
61+
}
62+
2163
public class CommandTests_Single_NoOptions_NoArgs : ConsoleAppBase
2264
{
2365
public void Hello() => Console.WriteLine("HelloMyWorld");

0 commit comments

Comments
 (0)