@@ -361,14 +361,8 @@ public static bool TryParse(string? value, out MyTryParsableRecord? result)
361
361
[ MemberData ( nameof ( TryParsableParameters ) ) ]
362
362
public async Task RequestDelegatePopulatesUnattributedTryParsableParametersFromRouteValue ( Delegate action , string ? routeValue , object ? expectedParameterValue )
363
363
{
364
- var invalidDataException = new InvalidDataException ( ) ;
365
- var serviceCollection = new ServiceCollection ( ) ;
366
- serviceCollection . AddSingleton ( LoggerFactory ) ;
367
-
368
364
var httpContext = new DefaultHttpContext ( ) ;
369
365
httpContext . Request . RouteValues [ "tryParsable" ] = routeValue ;
370
- httpContext . Features . Set < IHttpRequestLifetimeFeature > ( new TestHttpRequestLifetimeFeature ( ) ) ;
371
- httpContext . RequestServices = serviceCollection . BuildServiceProvider ( ) ;
372
366
373
367
var requestDelegate = RequestDelegateFactory . Create ( action ) ;
374
368
@@ -460,7 +454,6 @@ void TestAction([FromRoute] int tryParsable, [FromRoute] int tryParsable2)
460
454
invoked = true ;
461
455
}
462
456
463
- var invalidDataException = new InvalidDataException ( ) ;
464
457
var serviceCollection = new ServiceCollection ( ) ;
465
458
serviceCollection . AddSingleton ( LoggerFactory ) ;
466
459
@@ -588,18 +581,15 @@ public async Task RequestDelegatePopulatesFromBodyParameter(Delegate action)
588
581
Assert . Equal ( originalTodo . Name , ( ( Todo ) deserializedRequestBody ! ) . Name ) ;
589
582
}
590
583
591
- [ Fact ]
592
- public async Task RequestDelegateRejectsEmptyBodyGivenDefaultFromBodyParameter ( )
584
+ [ Theory ]
585
+ [ MemberData ( nameof ( FromBodyActions ) ) ]
586
+ public async Task RequestDelegateRejectsEmptyBodyGivenFromBodyParameter ( Delegate action )
593
587
{
594
- void TestAction ( Todo todo )
595
- {
596
- }
597
-
598
588
var httpContext = new DefaultHttpContext ( ) ;
599
589
httpContext . Request . Headers [ "Content-Type" ] = "application/json" ;
600
590
httpContext . Request . Headers [ "Content-Length" ] = "0" ;
601
591
602
- var requestDelegate = RequestDelegateFactory . Create ( ( Action < Todo > ) TestAction ) ;
592
+ var requestDelegate = RequestDelegateFactory . Create ( action ) ;
603
593
604
594
await Assert . ThrowsAsync < JsonException > ( ( ) => requestDelegate ( httpContext ) ) ;
605
595
}
@@ -775,7 +765,7 @@ public async Task RequestDelegatePopulatesParametersFromServiceWithAndWithoutAtt
775
765
public async Task RequestDelegateRequiresServiceForAllFromServiceParameters ( Delegate action )
776
766
{
777
767
var httpContext = new DefaultHttpContext ( ) ;
778
- httpContext . RequestServices = ( new ServiceCollection ( ) ) . BuildServiceProvider ( ) ;
768
+ httpContext . RequestServices = new ServiceCollection ( ) . BuildServiceProvider ( ) ;
779
769
780
770
var requestDelegate = RequestDelegateFactory . Create ( ( Action < HttpContext , MyService > ) action ) ;
781
771
0 commit comments