@@ -43,13 +43,13 @@ await WithConnectionAsync(
43
43
CreateConnection ( loggerFactory : LoggerFactory , transport : new TestTransport ( onTransportStart : SyncPoint . Create ( out var syncPoint ) ) ) ,
44
44
async ( connection ) =>
45
45
{
46
- var firstStart = connection . StartAsync ( TransferFormat . Text ) . OrTimeout ( ) ;
47
- await syncPoint . WaitForSyncPoint ( ) ;
48
- var secondStart = connection . StartAsync ( TransferFormat . Text ) . OrTimeout ( ) ;
46
+ var firstStart = connection . StartAsync ( TransferFormat . Text ) ;
47
+ await syncPoint . WaitForSyncPoint ( ) . OrTimeout ( ) ;
48
+ var secondStart = connection . StartAsync ( TransferFormat . Text ) ;
49
49
syncPoint . Continue ( ) ;
50
50
51
- await firstStart ;
52
- await secondStart ;
51
+ await firstStart . OrTimeout ( ) ;
52
+ await secondStart . OrTimeout ( ) ;
53
53
} ) ;
54
54
}
55
55
}
@@ -64,10 +64,10 @@ await WithConnectionAsync(
64
64
async ( connection ) =>
65
65
{
66
66
await connection . StartAsync ( TransferFormat . Text ) . OrTimeout ( ) ;
67
- await connection . DisposeAsync ( ) ;
67
+ await connection . DisposeAsync ( ) . OrTimeout ( ) ;
68
68
var exception =
69
69
await Assert . ThrowsAsync < ObjectDisposedException > (
70
- async ( ) => await connection . StartAsync ( TransferFormat . Text ) . OrTimeout ( ) ) ;
70
+ async ( ) => await connection . StartAsync ( TransferFormat . Text ) ) . OrTimeout ( ) ;
71
71
72
72
Assert . Equal ( nameof ( HttpConnection ) , exception . ObjectName ) ;
73
73
} ) ;
@@ -121,7 +121,7 @@ await WithConnectionAsync(
121
121
async ( connection ) =>
122
122
{
123
123
Assert . Equal ( 0 , startCounter ) ;
124
- await connection . StartAsync ( TransferFormat . Text ) ;
124
+ await connection . StartAsync ( TransferFormat . Text ) . OrTimeout ( ) ;
125
125
Assert . Equal ( passThreshold , startCounter ) ;
126
126
} ) ;
127
127
}
@@ -154,7 +154,7 @@ await WithConnectionAsync(
154
154
transport : new TestTransport ( onTransportStart : OnTransportStart ) ) ,
155
155
async ( connection ) =>
156
156
{
157
- var ex = await Assert . ThrowsAsync < AggregateException > ( ( ) => connection . StartAsync ( TransferFormat . Text ) ) ;
157
+ var ex = await Assert . ThrowsAsync < AggregateException > ( ( ) => connection . StartAsync ( TransferFormat . Text ) ) . OrTimeout ( ) ;
158
158
Assert . Equal ( "Unable to connect to the server with any of the available transports. " +
159
159
"(WebSockets failed: Transport failed to start) (ServerSentEvents failed: Transport failed to start) (LongPolling failed: Transport failed to start)" ,
160
160
ex . Message ) ;
@@ -179,8 +179,7 @@ await WithConnectionAsync(
179
179
CreateConnection ( loggerFactory : LoggerFactory ) ,
180
180
async ( connection ) =>
181
181
{
182
- await connection . DisposeAsync ( ) ;
183
-
182
+ await connection . DisposeAsync ( ) . OrTimeout ( ) ;
184
183
} ) ;
185
184
}
186
185
}
@@ -203,7 +202,7 @@ await WithConnectionAsync(
203
202
await transportStart . WaitForSyncPoint ( ) . OrTimeout ( ) ;
204
203
205
204
// While the transport is starting, dispose the connection
206
- var disposeTask = connection . DisposeAsync ( ) . OrTimeout ( ) ;
205
+ var disposeTask = connection . DisposeAsync ( ) ;
207
206
transportStart . Continue ( ) ; // We need to release StartAsync, because Dispose waits for it.
208
207
209
208
// Wait for start to finish, as that has to finish before the transport will be stopped.
@@ -214,7 +213,7 @@ await WithConnectionAsync(
214
213
transportStop . Continue ( ) ;
215
214
216
215
// Dispose should finish
217
- await disposeTask ;
216
+ await disposeTask . OrTimeout ( ) ;
218
217
} ) ;
219
218
}
220
219
}
@@ -234,22 +233,22 @@ await WithConnectionAsync(
234
233
await connection . StartAsync ( TransferFormat . Text ) . OrTimeout ( ) ;
235
234
236
235
// Dispose the connection
237
- var stopTask = connection . DisposeAsync ( ) . OrTimeout ( ) ;
236
+ var stopTask = connection . DisposeAsync ( ) ;
238
237
239
238
// Once the transport starts shutting down
240
- await transportStop . WaitForSyncPoint ( ) ;
239
+ await transportStop . WaitForSyncPoint ( ) . OrTimeout ( ) ;
241
240
Assert . False ( stopTask . IsCompleted ) ;
242
241
243
242
// Start disposing again, and then let the first dispose continue
244
- var disposeTask = connection . DisposeAsync ( ) . OrTimeout ( ) ;
243
+ var disposeTask = connection . DisposeAsync ( ) ;
245
244
transportStop . Continue ( ) ;
246
245
247
246
// Wait for the tasks to complete
248
247
await stopTask . OrTimeout ( ) ;
249
248
await disposeTask . OrTimeout ( ) ;
250
249
251
250
// We should be disposed and thus unable to restart.
252
- await AssertDisposedAsync ( connection ) ;
251
+ await AssertDisposedAsync ( connection ) . OrTimeout ( ) ;
253
252
} ) ;
254
253
}
255
254
}
@@ -316,7 +315,7 @@ await WithConnectionAsync(
316
315
await connection . Transport . Output . WriteAsync ( new byte [ ] { 0x42 } ) . OrTimeout ( ) ;
317
316
318
317
// We should get the exception in the transport input completion.
319
- await Assert . ThrowsAsync < HttpRequestException > ( ( ) => connection . Transport . Input . WaitForWriterToComplete ( ) ) ;
318
+ await Assert . ThrowsAsync < HttpRequestException > ( ( ) => connection . Transport . Input . WaitForWriterToComplete ( ) ) . OrTimeout ( ) ;
320
319
} ) ;
321
320
}
322
321
}
@@ -371,19 +370,19 @@ await WithConnectionAsync(
371
370
CreateConnection ( httpHandler , loggerFactory : LoggerFactory , transport : sse ) ,
372
371
async ( connection ) =>
373
372
{
374
- var startTask = connection . StartAsync ( TransferFormat . Text ) . OrTimeout ( ) ;
373
+ var startTask = connection . StartAsync ( TransferFormat . Text ) ;
375
374
Assert . False ( connectResponseTcs . Task . IsCompleted ) ;
376
375
Assert . False ( startTask . IsCompleted ) ;
377
376
connectResponseTcs . TrySetResult ( null ) ;
378
- await startTask ;
377
+ await startTask . OrTimeout ( ) ;
379
378
} ) ;
380
379
}
381
380
}
382
381
383
382
private static async Task AssertDisposedAsync ( HttpConnection connection )
384
383
{
385
384
var exception =
386
- await Assert . ThrowsAsync < ObjectDisposedException > ( ( ) => connection . StartAsync ( TransferFormat . Text ) . OrTimeout ( ) ) ;
385
+ await Assert . ThrowsAsync < ObjectDisposedException > ( ( ) => connection . StartAsync ( TransferFormat . Text ) ) ;
387
386
Assert . Equal ( nameof ( HttpConnection ) , exception . ObjectName ) ;
388
387
}
389
388
}
0 commit comments