@@ -79,32 +79,82 @@ public static void Main(string[] args)
7979 }
8080 }
8181
82+ static private string getSwitchValue ( string [ ] commandArgs , string switchName )
83+ {
84+ var index = Array . FindIndex ( commandArgs , v => v == switchName ) ;
85+ if ( index == - 1 )
86+ {
87+ return null ;
88+ }
89+ else
90+ {
91+ return commandArgs [ index + 1 ] ;
92+ }
93+ }
94+
95+ static private bool containsSwitch ( string [ ] commandArgs , string switchName )
96+ {
97+ Debug . Assert ( commandArgs != null ) ;
98+ Debug . Assert ( switchName != null ) ;
99+ return commandArgs . Contains ( switchName ) ;
100+ }
101+
82102
83103 public static void Test ( string [ ] commandArgs )
84104 {
85105 if ( EndpointTestDefinition . HasTestSuite ( EndpointCollection . SourceDirectory ) )
86106 {
87107 var testDefinitions = EndpointTestDefinition . ReadFromDirectory ( EndpointCollection . SourceDirectory ) ;
88- var errors = 0 ;
89- foreach ( var test in testDefinitions . Tests )
108+
109+ var only = getSwitchValue ( commandArgs , "--only" ) ;
110+ if ( only != null )
90111 {
91- Write ( test . Name . PadRight ( 60 ) ) ;
92- var result = test . ExecuteAsync ( EndpointCollection ) . Result ;
93- WriteLine ( result . ResultAsString ) ;
94- if ( result . Error )
112+ var index = int . Parse ( only ) ;
113+ var testCase = testDefinitions . Tests . ElementAt ( index ) ;
114+
115+ if ( containsSwitch ( commandArgs , "--showResponse" ) )
95116 {
96- errors ++ ;
117+ throw new NotImplementedException ( "TODO" ) ;
97118 }
119+ else
120+ {
121+ ExecuteTestAndOutputResult ( index , testCase ) ;
122+ }
123+
124+ return ;
98125 }
99- WriteLine ( ) ;
100- WriteLine ( $ "Total: { testDefinitions . Tests . Count ( ) } Errors: { errors } ") ;
126+ TestAll ( testDefinitions ) ;
101127 }
102128 else
103129 {
104130 Error . WriteLine ( "ERROR: No test suite found" ) ;
105131 }
106132 }
107133
134+ private static NetmockeryTestCaseResult ExecuteTestAndOutputResult ( int index , NetmockeryTestCase test )
135+ {
136+ Write ( $ "{ index . ToString ( ) . PadLeft ( 3 ) } { test . Name . PadRight ( 60 ) } ") ;
137+ var result = test . ExecuteAsync ( EndpointCollection ) . Result ;
138+ WriteLine ( result . ResultAsString ) ;
139+ return result ;
140+ }
141+
142+ public static void TestAll ( EndpointTestDefinition testDefinitions )
143+ {
144+ var errors = 0 ;
145+ var index = 0 ;
146+ foreach ( var test in testDefinitions . Tests )
147+ {
148+ var result = ExecuteTestAndOutputResult ( index ++ , test ) ;
149+ if ( result . Error )
150+ {
151+ errors ++ ;
152+ }
153+ }
154+ WriteLine ( ) ;
155+ WriteLine ( $ "Total: { testDefinitions . Tests . Count ( ) } Errors: { errors } ") ;
156+ }
157+
108158
109159 public static void RunScript ( string [ ] commandArgs )
110160 {
0 commit comments