2
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
4
4
using System . CommandLine . Rendering ;
5
+ using System . ComponentModel ;
5
6
using System . Threading . Tasks ;
6
7
using FluentAssertions ;
7
8
using Xunit ;
@@ -24,7 +25,7 @@ public async Task It_executes_method_with_string_option()
24
25
{
25
26
int exitCode = await CommandLine . InvokeMethodAsync (
26
27
new [ ] { "--name" , "Wayne" } ,
27
- TestProgram . TestMainMethodInfo ,
28
+ TestProgram . TestMainMethodInfoWithoutPara ,
28
29
null ,
29
30
_testProgram ,
30
31
_terminal ) ;
@@ -37,7 +38,7 @@ public void It_executes_method_synchronously_with_string_option()
37
38
{
38
39
int exitCode = CommandLine . InvokeMethod (
39
40
new [ ] { "--name" , "Wayne" } ,
40
- TestProgram . TestMainMethodInfo ,
41
+ TestProgram . TestMainMethodInfoWithoutPara ,
41
42
null ,
42
43
_testProgram ,
43
44
_terminal ) ;
@@ -50,7 +51,7 @@ public async Task It_shows_help_text_based_on_XML_documentation_comments()
50
51
{
51
52
int exitCode = await CommandLine . InvokeMethodAsync (
52
53
new [ ] { "--help" } ,
53
- TestProgram . TestMainMethodInfo ,
54
+ TestProgram . TestMainMethodInfoWithoutPara ,
54
55
null ,
55
56
_testProgram ,
56
57
_terminal ) ;
@@ -60,23 +61,23 @@ public async Task It_shows_help_text_based_on_XML_documentation_comments()
60
61
var stdOut = _terminal . Out . ToString ( ) ;
61
62
62
63
stdOut . Should ( )
63
- . Contain ( "<args> These are arguments" )
64
- . And . Contain ( "Arguments:" ) ;
64
+ . Contain ( "<args> These are arguments" )
65
+ . And . Contain ( "Arguments:" ) ;
65
66
stdOut . Should ( )
66
- . ContainAll ( "--name <name>" , "Specifies the name option" )
67
- . And . Contain ( "Options:" ) ;
67
+ . ContainAll ( "--name <name>" , "Specifies the name option" )
68
+ . And . Contain ( "Options:" ) ;
68
69
stdOut . Should ( )
69
- . Contain ( "Help for the test program ") ;
70
+ . Contain ( $ "Description: { Environment . NewLine } Normal summary ") ;
70
71
}
71
-
72
+
72
73
[ Fact ]
73
- public void It_synchronously_shows_help_text_based_on_XML_documentation_comments ( )
74
+ public async Task When_XML_documentation_comment_contains_a_para_tag_then_help_is_written_with_a_newline ( )
74
75
{
75
- int exitCode = CommandLine . InvokeMethod (
76
+ int exitCode = await CommandLine . InvokeMethodAsync (
76
77
new [ ] { "--help" } ,
77
- TestProgram . TestMainMethodInfo ,
78
+ TestProgram . TestMainMethodInfoWithPara ,
78
79
null ,
79
- _testProgram ,
80
+ _testProgram ,
80
81
_terminal ) ;
81
82
82
83
exitCode . Should ( ) . Be ( 0 ) ;
@@ -87,10 +88,29 @@ public void It_synchronously_shows_help_text_based_on_XML_documentation_comments
87
88
. Contain ( "<args> These are arguments" )
88
89
. And . Contain ( "Arguments:" ) ;
89
90
stdOut . Should ( )
90
- . ContainAll ( "--name <name>" , "Specifies the name option" )
91
+ . ContainAll ( "--name <name>" , "Specifies the name option" )
91
92
. And . Contain ( "Options:" ) ;
92
93
stdOut . Should ( )
93
- . Contain ( "Help for the test program" ) ;
94
+ . Contain ( $ "Description:{ Environment . NewLine } Help for the test program{ Environment . NewLine } More help for the test program{ Environment . NewLine } ") ;
95
+ }
96
+
97
+ [ Fact ]
98
+ public void It_synchronously_shows_help_text_based_on_XML_documentation_comments ( )
99
+ {
100
+ int exitCode = CommandLine . InvokeMethod (
101
+ new [ ] { "--help" } ,
102
+ TestProgram . TestMainMethodInfoWithDefault ,
103
+ null ,
104
+ _testProgram ,
105
+ _terminal ) ;
106
+
107
+ exitCode . Should ( ) . Be ( 0 ) ;
108
+
109
+ var stdOut = _terminal . Out . ToString ( ) ;
110
+
111
+ stdOut . Should ( )
112
+ . ContainAll ( "--name <name>" , "name [default: Bruce]" )
113
+ . And . Contain ( "Options:" ) ;
94
114
}
95
115
96
116
[ Fact ]
0 commit comments