@@ -100,7 +100,15 @@ public async Task RunTcp(TestCase testCase)
100100
101101 if ( testCase . result . status == "SUCCESS" )
102102 {
103- WaitAssert ( srv , testCase . result . line + "\n " ) ;
103+ if ( testCase . result . anyLines == null || testCase . result . anyLines . Length == 0 )
104+ {
105+ WaitAssert ( srv , testCase . result . line + "\n " ) ;
106+ }
107+ else
108+ {
109+ WaitAssert ( srv , testCase . result . anyLines ) ;
110+ }
111+
104112 }
105113 else if ( testCase . result . status == "ERROR" )
106114 {
@@ -180,14 +188,19 @@ public async Task RunHttp(TestCase testCase)
180188
181189 if ( testCase . result . status == "SUCCESS" )
182190 {
183- Assert . That (
184- server . GetReceiveBuffer ( ) . ToString ( ) ,
185- Is . EqualTo ( testCase . result . line + "\n " )
186- ) ;
191+ var textReceived = server . GetReceiveBuffer ( ) . ToString ( ) ;
192+ if ( testCase . result . anyLines == null || testCase . result . anyLines . Length == 0 )
193+ {
194+ Assert . That ( textReceived , Is . EqualTo ( testCase . result . line + "\n " ) ) ;
195+ }
196+ else
197+ {
198+ AssertMany ( testCase . result . anyLines , textReceived ) ;
199+ }
187200 }
188201 else if ( testCase . result . status == "ERROR" )
189202 {
190- Assert . NotNull ( exception , $ "Exception should be thrown: { exception } ") ;
203+ Assert . NotNull ( exception , "Exception should be thrown" ) ;
191204 if ( exception is NotSupportedException )
192205 {
193206 throw exception ;
@@ -197,8 +210,27 @@ public async Task RunHttp(TestCase testCase)
197210 {
198211 Assert . Fail ( "Unsupported test case result status: " + testCase . result . status ) ;
199212 }
213+ }
200214
201- await server . StopAsync ( ) ;
215+ private void WaitAssert ( DummyIlpServer srv , string [ ] resultAnyLines )
216+ {
217+ var minExpectedLen = resultAnyLines . Select ( l => Encoding . UTF8 . GetBytes ( l ) . Length ) . Min ( ) ;
218+ for ( var i = 0 ; i < 500 && srv . TotalReceived < minExpectedLen ; i ++ )
219+ {
220+ Thread . Sleep ( 10 ) ;
221+ }
222+
223+ var textReceived = srv . GetTextReceived ( ) ;
224+ AssertMany ( resultAnyLines , textReceived ) ;
225+ }
226+
227+ private static void AssertMany ( string [ ] resultAnyLines , string textReceived )
228+ {
229+ bool anyMatch = resultAnyLines . Any ( l => l . Equals ( textReceived ) || ( l + "\n " ) . Equals ( textReceived ) ) ;
230+ if ( ! anyMatch )
231+ {
232+ Assert . Fail ( textReceived + ": did not match any expected results" ) ;
233+ }
202234 }
203235
204236 private static void WaitAssert ( DummyIlpServer srv , string expected )
@@ -254,5 +286,6 @@ public class TestCaseResult
254286 {
255287 public string status { get ; set ; }
256288 public string line { get ; set ; }
289+ public string [ ] ? anyLines { get ; set ; }
257290 }
258291}
0 commit comments