@@ -100,7 +100,15 @@ public async Task RunTcp(TestCase testCase)
100
100
101
101
if ( testCase . result . status == "SUCCESS" )
102
102
{
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
+
104
112
}
105
113
else if ( testCase . result . status == "ERROR" )
106
114
{
@@ -180,14 +188,19 @@ public async Task RunHttp(TestCase testCase)
180
188
181
189
if ( testCase . result . status == "SUCCESS" )
182
190
{
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
+ }
187
200
}
188
201
else if ( testCase . result . status == "ERROR" )
189
202
{
190
- Assert . NotNull ( exception , $ "Exception should be thrown: { exception } ") ;
203
+ Assert . NotNull ( exception , "Exception should be thrown" ) ;
191
204
if ( exception is NotSupportedException )
192
205
{
193
206
throw exception ;
@@ -197,8 +210,27 @@ public async Task RunHttp(TestCase testCase)
197
210
{
198
211
Assert . Fail ( "Unsupported test case result status: " + testCase . result . status ) ;
199
212
}
213
+ }
200
214
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
+ }
202
234
}
203
235
204
236
private static void WaitAssert ( DummyIlpServer srv , string expected )
@@ -254,5 +286,6 @@ public class TestCaseResult
254
286
{
255
287
public string status { get ; set ; }
256
288
public string line { get ; set ; }
289
+ public string [ ] ? anyLines { get ; set ; }
257
290
}
258
291
}
0 commit comments