18
18
using Microsoft . AspNetCore . Server . Kestrel . InMemory . FunctionalTests . TestTransport ;
19
19
using Microsoft . AspNetCore . Testing ;
20
20
using Microsoft . Extensions . Logging . Testing ;
21
- using Moq ;
22
21
using Xunit ;
23
22
24
23
namespace Microsoft . AspNetCore . Server . Kestrel . InMemory . FunctionalTests
@@ -731,9 +730,11 @@ await connection.ReceiveEnd(
731
730
[ Fact ]
732
731
public async Task ConnectionClosesWhenFinReceivedBeforeRequestCompletes ( )
733
732
{
734
- var testContext = new TestServiceContext ( LoggerFactory ) ;
735
- // FIN callbacks are scheduled so run inline to make this test more reliable
736
- testContext . Scheduler = PipeScheduler . Inline ;
733
+ var testContext = new TestServiceContext ( LoggerFactory )
734
+ {
735
+ // FIN callbacks are scheduled so run inline to make this test more reliable
736
+ Scheduler = PipeScheduler . Inline
737
+ } ;
737
738
738
739
using ( var server = new TestServer ( TestApp . EchoAppChunked , testContext ) )
739
740
{
@@ -1317,7 +1318,24 @@ public async Task SynchronousReadsCanBeAllowedGlobally()
1317
1318
1318
1319
Assert . Equal ( 0 , await context . Request . Body . ReadAsync ( new byte [ 1 ] , 0 , 1 ) ) ;
1319
1320
Assert . Equal ( "Hello" , Encoding . ASCII . GetString ( buffer , 0 , 5 ) ) ;
1320
- } ) ) ;
1321
+ } , testContext ) )
1322
+ {
1323
+ using ( var connection = server . CreateConnection ( ) )
1324
+ {
1325
+ await connection . Send (
1326
+ "POST / HTTP/1.1" ,
1327
+ "Host:" ,
1328
+ "Content-Length: 5" ,
1329
+ "" ,
1330
+ "Hello" ) ;
1331
+ await connection . Receive (
1332
+ "HTTP/1.1 200 OK" ,
1333
+ $ "Date: { server . Context . DateHeaderValue } ",
1334
+ "Content-Length: 0" ,
1335
+ "" ,
1336
+ "" ) ;
1337
+ }
1338
+ }
1321
1339
}
1322
1340
1323
1341
[ Fact ]
@@ -1394,6 +1412,7 @@ public async Task ContentLengthRequestCallCompleteThrowsExceptionOnRead()
1394
1412
response . Headers [ "Content-Length" ] = new [ ] { "11" } ;
1395
1413
1396
1414
await response . BodyPipe . WriteAsync ( new Memory < byte > ( Encoding . ASCII . GetBytes ( "Hello World" ) , 0 , 11 ) ) ;
1415
+
1397
1416
} , testContext ) )
1398
1417
{
1399
1418
using ( var connection = server . CreateConnection ( ) )
@@ -1404,12 +1423,6 @@ await connection.Send(
1404
1423
"Content-Length: 5" ,
1405
1424
"" ,
1406
1425
"Hello" ) ;
1407
- await connection . Receive (
1408
- "HTTP/1.1 200 OK" ,
1409
- $ "Date: { server . Context . DateHeaderValue } ",
1410
- "Content-Length: 0" ,
1411
- "" ,
1412
- "" ) ;
1413
1426
1414
1427
await connection . Receive (
1415
1428
"HTTP/1.1 200 OK" ,
0 commit comments