@@ -11,18 +11,18 @@ namespace System.CommandLine.Subsystems.Tests;
1111public class ValidationSubsystemTests
1212{
1313 // Running exactly the same code is important here because missing a step will result in a false positive. Ask me how I know
14- private CliOption GetOptionWithSimpleRange < T > ( T lowerBound , T upperBound )
14+ private CliOption < T > GetOptionWithSimpleRange < T > ( string name , T lowerBound , T upperBound )
1515 where T : IComparable < T >
1616 {
17- var option = new CliOption < int > ( "--intOpt" ) ;
17+ var option = new CliOption < T > ( name ) ;
1818 option . SetRange ( lowerBound , upperBound ) ;
1919 return option ;
2020 }
2121
22- private CliOption GetOptionWithRangeBounds < T > ( ValueSource < T > lowerBound , ValueSource < T > upperBound )
22+ private CliOption < T > GetOptionWithRangeBounds < T > ( string name , ValueSource < T > lowerBound , ValueSource < T > upperBound )
2323 where T : IComparable < T >
2424 {
25- var option = new CliOption < int > ( "--intOpt" ) ;
25+ var option = new CliOption < T > ( name ) ;
2626 option . SetRange ( lowerBound , upperBound ) ;
2727 return option ;
2828 }
@@ -45,7 +45,7 @@ private PipelineResult ExecutedPipelineResultForCommand(CliCommand command, stri
4545 [ Fact ]
4646 public void Int_values_in_specified_range_do_not_have_errors ( )
4747 {
48- var option = GetOptionWithSimpleRange ( 0 , 50 ) ;
48+ var option = GetOptionWithSimpleRange ( "--intOpt" , 0 , 50 ) ;
4949
5050 var pipelineResult = ExecutedPipelineResultForRangeOption ( option , "--intOpt 42" ) ;
5151
@@ -56,7 +56,7 @@ public void Int_values_in_specified_range_do_not_have_errors()
5656 [ Fact ]
5757 public void Int_values_above_upper_bound_report_error ( )
5858 {
59- var option = GetOptionWithSimpleRange ( 0 , 5 ) ;
59+ var option = GetOptionWithSimpleRange ( "--intOpt" , 0 , 5 ) ;
6060
6161 var pipelineResult = ExecutedPipelineResultForRangeOption ( option , "--intOpt 42" ) ;
6262
@@ -69,7 +69,7 @@ public void Int_values_above_upper_bound_report_error()
6969 [ Fact ]
7070 public void Int_below_lower_bound_report_error ( )
7171 {
72- var option = GetOptionWithSimpleRange ( 0 , 5 ) ;
72+ var option = GetOptionWithSimpleRange ( "--intOpt" , 0 , 5 ) ;
7373
7474 var pipelineResult = ExecutedPipelineResultForRangeOption ( option , "--intOpt -42" ) ;
7575
@@ -82,7 +82,7 @@ public void Int_below_lower_bound_report_error()
8282 [ Fact ]
8383 public void Int_values_on_lower_range_bound_do_not_report_error ( )
8484 {
85- var option = GetOptionWithSimpleRange ( 42 , 50 ) ;
85+ var option = GetOptionWithSimpleRange ( "--intOpt" , 42 , 50 ) ;
8686
8787 var pipelineResult = ExecutedPipelineResultForRangeOption ( option , "--intOpt 42" ) ;
8888
@@ -93,7 +93,7 @@ public void Int_values_on_lower_range_bound_do_not_report_error()
9393 [ Fact ]
9494 public void Int_values_on_upper_range_bound_do_not_report_error ( )
9595 {
96- var option = GetOptionWithSimpleRange ( 0 , 42 ) ;
96+ var option = GetOptionWithSimpleRange ( "--intOpt" , 0 , 42 ) ;
9797
9898 var pipelineResult = ExecutedPipelineResultForRangeOption ( option , "--intOpt 42" ) ;
9999
@@ -104,7 +104,7 @@ public void Int_values_on_upper_range_bound_do_not_report_error()
104104 [ Fact ]
105105 public void Values_below_calculated_lower_bound_report_error ( )
106106 {
107- var option = GetOptionWithRangeBounds < int > ( ValueSource . Create ( ( ) => ( true , 1 ) ) , 50 ) ;
107+ var option = GetOptionWithRangeBounds < int > ( "--intOpt" , ValueSource . Create ( ( ) => ( true , 1 ) ) , 50 ) ;
108108
109109 var pipelineResult = ExecutedPipelineResultForRangeOption ( option , "--intOpt 0" ) ;
110110
@@ -118,7 +118,7 @@ public void Values_below_calculated_lower_bound_report_error()
118118 [ Fact ]
119119 public void Values_within_calculated_range_do_not_report_error ( )
120120 {
121- var option = GetOptionWithRangeBounds ( ValueSource < int > . Create ( ( ) => ( true , 1 ) ) , ValueSource < int > . Create ( ( ) => ( true , 50 ) ) ) ;
121+ var option = GetOptionWithRangeBounds ( "--intOpt" , ValueSource . Create ( ( ) => ( true , 1 ) ) , ValueSource . Create ( ( ) => ( true , 50 ) ) ) ;
122122
123123 var pipelineResult = ExecutedPipelineResultForRangeOption ( option , "--intOpt 42" ) ;
124124
@@ -129,7 +129,7 @@ public void Values_within_calculated_range_do_not_report_error()
129129 [ Fact ]
130130 public void Values_above_calculated_upper_bound_report_error ( )
131131 {
132- var option = GetOptionWithRangeBounds ( 0 , ValueSource < int > . Create ( ( ) => ( true , 40 ) ) ) ;
132+ var option = GetOptionWithRangeBounds ( "--intOpt" , 0 , ValueSource . Create ( ( ) => ( true , 40 ) ) ) ;
133133
134134 var pipelineResult = ExecutedPipelineResultForRangeOption ( option , "--intOpt 42" ) ;
135135
@@ -143,7 +143,7 @@ public void Values_above_calculated_upper_bound_report_error()
143143 public void Values_below_relative_lower_bound_report_error ( )
144144 {
145145 var otherOption = new CliOption < int > ( "-a" ) ;
146- var option = GetOptionWithRangeBounds ( ValueSource . Create ( otherOption , o => ( true , ( int ) o + 1 ) ) , 50 ) ;
146+ var option = GetOptionWithRangeBounds ( "--intOpt" , ValueSource . Create < int > ( otherOption , o => ( true , o + 1 ) ) , 50 ) ;
147147 var command = new CliCommand ( "cmd" ) { option , otherOption } ;
148148
149149 var pipelineResult = ExecutedPipelineResultForCommand ( command , "--intOpt 0 -a 0" ) ;
@@ -159,7 +159,9 @@ public void Values_below_relative_lower_bound_report_error()
159159 public void Values_within_relative_range_do_not_report_error ( )
160160 {
161161 var otherOption = new CliOption < int > ( "-a" ) ;
162- var option = GetOptionWithRangeBounds ( ValueSource < int > . Create ( otherOption , o => ( true , ( int ) o + 1 ) ) , ValueSource < int > . Create ( otherOption , o => ( true , ( int ) o + 10 ) ) ) ;
162+ var option = GetOptionWithRangeBounds ( "--intOpt" ,
163+ ValueSource . Create < int > ( otherOption , o => ( true , o + 1 ) ) ,
164+ ValueSource . Create < int > ( otherOption , o => ( true , o + 10 ) ) ) ;
163165 var command = new CliCommand ( "cmd" ) { option , otherOption } ;
164166
165167 var pipelineResult = ExecutedPipelineResultForCommand ( command , "--intOpt 11 -a 3" ) ;
@@ -172,7 +174,7 @@ public void Values_within_relative_range_do_not_report_error()
172174 public void Values_above_relative_upper_bound_report_error ( )
173175 {
174176 var otherOption = new CliOption < int > ( "-a" ) ;
175- var option = GetOptionWithRangeBounds ( 0 , ValueSource < int > . Create ( otherOption , o => ( true , ( int ) o + 10 ) ) ) ;
177+ var option = GetOptionWithRangeBounds ( "--intOpt" , 0 , ValueSource . Create < int > ( otherOption , o => ( true , o + 10 ) ) ) ;
176178 var command = new CliCommand ( "cmd" ) { option , otherOption } ;
177179
178180 var pipelineResult = ExecutedPipelineResultForCommand ( command , "--intOpt 9 -a -2" ) ;
0 commit comments