@@ -59,7 +59,7 @@ public class CustomParsing
59
59
[ Fact ]
60
60
public void HasDefaultValue_can_be_set_to_true ( )
61
61
{
62
- var argument = new Argument < FileSystemInfo > ( result => true , true ) ;
62
+ var argument = new Argument < FileSystemInfo > ( result => null , true ) ;
63
63
64
64
argument . HasDefaultValue
65
65
. Should ( )
@@ -69,7 +69,7 @@ public void HasDefaultValue_can_be_set_to_true()
69
69
[ Fact ]
70
70
public void HasDefaultValue_can_be_set_to_false ( )
71
71
{
72
- var argument = new Argument < FileSystemInfo > ( result => true , false ) ;
72
+ var argument = new Argument < FileSystemInfo > ( result => null , false ) ;
73
73
74
74
argument . HasDefaultValue
75
75
. Should ( )
@@ -79,11 +79,7 @@ public void HasDefaultValue_can_be_set_to_false()
79
79
[ Fact ]
80
80
public void GetDefaultValue_returns_specified_value ( )
81
81
{
82
- var argument = new Argument < string > ( result =>
83
- {
84
- result . Value = "the-default" ;
85
- return true ;
86
- } , isDefault : true ) ;
82
+ var argument = new Argument < string > ( result => "the-default" , isDefault : true ) ;
87
83
88
84
argument . GetDefaultValue ( )
89
85
. Should ( )
@@ -93,7 +89,7 @@ public void GetDefaultValue_returns_specified_value()
93
89
[ Fact ]
94
90
public void GetDefaultValue_returns_null_when_parse_delegate_returns_true_without_setting_a_value ( )
95
91
{
96
- var argument = new Argument < string > ( result => { return true ; } , isDefault : true ) ;
92
+ var argument = new Argument < string > ( result => null , isDefault : true ) ;
97
93
98
94
argument . GetDefaultValue ( )
99
95
. Should ( )
@@ -103,7 +99,7 @@ public void GetDefaultValue_returns_null_when_parse_delegate_returns_true_withou
103
99
[ Fact ]
104
100
public void GetDefaultValue_returns_null_when_parse_delegate_returns_true_and_sets_value_to_null ( )
105
101
{
106
- var argument = new Argument < string > ( result => { return true ; } , isDefault : true ) ;
102
+ var argument = new Argument < string > ( result => null , isDefault : true ) ;
107
103
108
104
argument . GetDefaultValue ( )
109
105
. Should ( )
@@ -113,7 +109,7 @@ public void GetDefaultValue_returns_null_when_parse_delegate_returns_true_and_se
113
109
[ Fact ]
114
110
public void GetDefaultValue_can_return_null ( )
115
111
{
116
- var argument = new Argument < string > ( result => { return true ; } , isDefault : true ) ;
112
+ var argument = new Argument < string > ( result => null , isDefault : true ) ;
117
113
118
114
argument . GetDefaultValue ( )
119
115
. Should ( )
@@ -126,7 +122,7 @@ public void validation_failure_message()
126
122
var argument = new Argument < FileSystemInfo > ( result =>
127
123
{
128
124
result . ErrorMessage = "oops!" ;
129
- return true ;
125
+ return null ;
130
126
} ) ;
131
127
132
128
argument . Parse ( "x" )
@@ -142,12 +138,7 @@ public void validation_failure_message()
142
138
[ Fact ]
143
139
public void custom_parsing_of_scalar_value_from_an_argument_with_one_token ( )
144
140
{
145
- var argument = new Argument < int > ( result =>
146
- {
147
- result . Value = int . Parse ( result . Tokens . Single ( ) . Value ) ;
148
-
149
- return true ;
150
- } ) ;
141
+ var argument = new Argument < int > ( result => int . Parse ( result . Tokens . Single ( ) . Value ) ) ;
151
142
152
143
argument . Parse ( "123" )
153
144
. FindResultFor ( argument )
@@ -159,12 +150,7 @@ public void custom_parsing_of_scalar_value_from_an_argument_with_one_token()
159
150
[ Fact ]
160
151
public void custom_parsing_of_sequence_value_from_an_argument_with_one_token ( )
161
152
{
162
- var argument = new Argument < IEnumerable < int > > ( result =>
163
- {
164
- result . Value = result . Tokens . Single ( ) . Value . Split ( ',' ) . Select ( int . Parse ) ;
165
-
166
- return true ;
167
- } ) ;
153
+ var argument = new Argument < IEnumerable < int > > ( result => result . Tokens . Single ( ) . Value . Split ( ',' ) . Select ( int . Parse ) ) ;
168
154
169
155
argument . Parse ( "1,2,3" )
170
156
. FindResultFor ( argument )
@@ -178,8 +164,7 @@ public void custom_parsing_of_sequence_value_from_an_argument_with_multiple_toke
178
164
{
179
165
var argument = new Argument < IEnumerable < int > > ( result =>
180
166
{
181
- result . Value = result . Tokens . Select ( t => int . Parse ( t . Value ) ) . ToArray ( ) ;
182
- return true ;
167
+ return result . Tokens . Select ( t => int . Parse ( t . Value ) ) . ToArray ( ) ;
183
168
} ) ;
184
169
185
170
argument . Parse ( "1 2 3" )
@@ -192,13 +177,10 @@ public void custom_parsing_of_sequence_value_from_an_argument_with_multiple_toke
192
177
[ Fact ]
193
178
public void custom_parsing_of_scalar_value_from_an_argument_with_multiple_tokens ( )
194
179
{
195
- var argument = new Argument < int > ( result =>
180
+ var argument = new Argument < int > ( result => result . Tokens . Select ( t => int . Parse ( t . Value ) ) . Sum ( ) )
196
181
{
197
- result . Value = result . Tokens . Select ( t => int . Parse ( t . Value ) ) . Sum ( ) ;
198
- return true ;
199
- } ) ;
200
-
201
- argument . Arity = ArgumentArity . ZeroOrMore ;
182
+ Arity = ArgumentArity . ZeroOrMore
183
+ } ;
202
184
203
185
argument . Parse ( "1 2 3" )
204
186
. FindResultFor ( argument )
0 commit comments