@@ -86,7 +86,7 @@ public async Task RequestDelegateInvokesAction(Delegate @delegate)
86
86
{
87
87
var httpContext = new DefaultHttpContext ( ) ;
88
88
89
- var requestDelegate = RequestDelegateFactory . Build ( @delegate ) ;
89
+ var requestDelegate = RequestDelegateFactory . Create ( @delegate ) ;
90
90
91
91
await requestDelegate ( httpContext ) ;
92
92
@@ -106,7 +106,7 @@ public async Task StaticMethodInfoOverloadWorksWithBasicReflection()
106
106
BindingFlags . NonPublic | BindingFlags . Static ,
107
107
new [ ] { typeof ( HttpContext ) } ) ;
108
108
109
- var requestDelegate = RequestDelegateFactory . Build ( methodInfo ! ) ;
109
+ var requestDelegate = RequestDelegateFactory . Create ( methodInfo ! ) ;
110
110
111
111
var httpContext = new DefaultHttpContext ( ) ;
112
112
@@ -151,7 +151,7 @@ object GetTarget()
151
151
return new TestNonStaticActionClass ( 2 ) ;
152
152
}
153
153
154
- var requestDelegate = RequestDelegateFactory . Build ( methodInfo ! , _ => GetTarget ( ) ) ;
154
+ var requestDelegate = RequestDelegateFactory . Create ( methodInfo ! , _ => GetTarget ( ) ) ;
155
155
156
156
var httpContext = new DefaultHttpContext ( ) ;
157
157
@@ -174,10 +174,10 @@ public void BuildRequestDelegateThrowsArgumentNullExceptions()
174
174
BindingFlags . NonPublic | BindingFlags . Static ,
175
175
new [ ] { typeof ( HttpContext ) } ) ;
176
176
177
- var exNullAction = Assert . Throws < ArgumentNullException > ( ( ) => RequestDelegateFactory . Build ( action : null ! ) ) ;
178
- var exNullMethodInfo1 = Assert . Throws < ArgumentNullException > ( ( ) => RequestDelegateFactory . Build ( methodInfo : null ! ) ) ;
179
- var exNullMethodInfo2 = Assert . Throws < ArgumentNullException > ( ( ) => RequestDelegateFactory . Build ( methodInfo : null ! , _ => 0 ) ) ;
180
- var exNullTargetFactory = Assert . Throws < ArgumentNullException > ( ( ) => RequestDelegateFactory . Build ( methodInfo ! , targetFactory : null ! ) ) ;
177
+ var exNullAction = Assert . Throws < ArgumentNullException > ( ( ) => RequestDelegateFactory . Create ( action : null ! ) ) ;
178
+ var exNullMethodInfo1 = Assert . Throws < ArgumentNullException > ( ( ) => RequestDelegateFactory . Create ( methodInfo : null ! ) ) ;
179
+ var exNullMethodInfo2 = Assert . Throws < ArgumentNullException > ( ( ) => RequestDelegateFactory . Create ( methodInfo : null ! , _ => 0 ) ) ;
180
+ var exNullTargetFactory = Assert . Throws < ArgumentNullException > ( ( ) => RequestDelegateFactory . Create ( methodInfo ! , targetFactory : null ! ) ) ;
181
181
182
182
Assert . Equal ( "action" , exNullAction . ParamName ) ;
183
183
Assert . Equal ( "methodInfo" , exNullMethodInfo1 . ParamName ) ;
@@ -229,7 +229,7 @@ public async Task RequestDelegatePopulatesFromRouteParameterBasedOnParameterName
229
229
var httpContext = new DefaultHttpContext ( ) ;
230
230
httpContext . Request . RouteValues [ paramName ] = originalRouteParam . ToString ( NumberFormatInfo . InvariantInfo ) ;
231
231
232
- var requestDelegate = RequestDelegateFactory . Build ( @delegate ) ;
232
+ var requestDelegate = RequestDelegateFactory . Create ( @delegate ) ;
233
233
234
234
await requestDelegate ( httpContext ) ;
235
235
@@ -272,7 +272,7 @@ public async Task RequestDelegatePopulatesFromRouteOptionalParameter(Delegate @d
272
272
{
273
273
var httpContext = new DefaultHttpContext ( ) ;
274
274
275
- var requestDelegate = RequestDelegateFactory . Build ( @delegate ) ;
275
+ var requestDelegate = RequestDelegateFactory . Create ( @delegate ) ;
276
276
277
277
await requestDelegate ( httpContext ) ;
278
278
@@ -290,7 +290,7 @@ public async Task RequestDelegatePopulatesFromRouteOptionalParameterBasedOnParam
290
290
291
291
httpContext . Request . RouteValues [ paramName ] = originalRouteParam . ToString ( NumberFormatInfo . InvariantInfo ) ;
292
292
293
- var requestDelegate = RequestDelegateFactory . Build ( @delegate ) ;
293
+ var requestDelegate = RequestDelegateFactory . Create ( @delegate ) ;
294
294
295
295
await requestDelegate ( httpContext ) ;
296
296
@@ -313,7 +313,7 @@ void TestAction([FromRoute(Name = specifiedName)] int foo)
313
313
var httpContext = new DefaultHttpContext ( ) ;
314
314
httpContext . Request . RouteValues [ specifiedName ] = originalRouteParam . ToString ( NumberFormatInfo . InvariantInfo ) ;
315
315
316
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < int > ) TestAction ) ;
316
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < int > ) TestAction ) ;
317
317
318
318
await requestDelegate ( httpContext ) ;
319
319
@@ -336,7 +336,7 @@ void TestAction([FromRoute] int foo)
336
336
var httpContext = new DefaultHttpContext ( ) ;
337
337
httpContext . Request . RouteValues [ unmatchedName ] = unmatchedRouteParam . ToString ( NumberFormatInfo . InvariantInfo ) ;
338
338
339
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < int > ) TestAction ) ;
339
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < int > ) TestAction ) ;
340
340
341
341
await requestDelegate ( httpContext ) ;
342
342
@@ -364,7 +364,7 @@ void TestAction([FromQuery] int value)
364
364
var httpContext = new DefaultHttpContext ( ) ;
365
365
httpContext . Request . Query = query ;
366
366
367
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < int > ) TestAction ) ;
367
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < int > ) TestAction ) ;
368
368
369
369
await requestDelegate ( httpContext ) ;
370
370
@@ -387,7 +387,7 @@ void TestAction([FromHeader(Name = customHeaderName)] int value)
387
387
var httpContext = new DefaultHttpContext ( ) ;
388
388
httpContext . Request . Headers [ customHeaderName ] = originalHeaderParam . ToString ( NumberFormatInfo . InvariantInfo ) ;
389
389
390
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < int > ) TestAction ) ;
390
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < int > ) TestAction ) ;
391
391
392
392
await requestDelegate ( httpContext ) ;
393
393
@@ -415,7 +415,7 @@ void TestAction([FromBody] Todo todo)
415
415
var requestBodyBytes = JsonSerializer . SerializeToUtf8Bytes ( originalTodo ) ;
416
416
httpContext . Request . Body = new MemoryStream ( requestBodyBytes ) ;
417
417
418
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < Todo > ) TestAction ) ;
418
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < Todo > ) TestAction ) ;
419
419
420
420
await requestDelegate ( httpContext ) ;
421
421
@@ -434,7 +434,7 @@ void TestAction([FromBody] Todo todo)
434
434
httpContext . Request . Headers [ "Content-Type" ] = "application/json" ;
435
435
httpContext . Request . Headers [ "Content-Length" ] = "0" ;
436
436
437
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < Todo > ) TestAction ) ;
437
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < Todo > ) TestAction ) ;
438
438
439
439
await Assert . ThrowsAsync < JsonException > ( ( ) => requestDelegate ( httpContext ) ) ;
440
440
}
@@ -453,7 +453,7 @@ void TestAction([FromBody(AllowEmpty = true)] Todo todo)
453
453
httpContext . Request . Headers [ "Content-Type" ] = "application/json" ;
454
454
httpContext . Request . Headers [ "Content-Length" ] = "0" ;
455
455
456
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < Todo > ) TestAction ) ;
456
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < Todo > ) TestAction ) ;
457
457
458
458
await requestDelegate ( httpContext ) ;
459
459
@@ -477,7 +477,7 @@ void TestAction([FromBody(AllowEmpty = true)] BodyStruct bodyStruct)
477
477
httpContext . Request . Headers [ "Content-Type" ] = "application/json" ;
478
478
httpContext . Request . Headers [ "Content-Length" ] = "0" ;
479
479
480
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < BodyStruct > ) TestAction ) ;
480
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < BodyStruct > ) TestAction ) ;
481
481
482
482
await requestDelegate ( httpContext ) ;
483
483
@@ -507,7 +507,7 @@ void TestAction([FromBody] Todo todo)
507
507
httpContext . Features . Set < IHttpRequestLifetimeFeature > ( new TestHttpRequestLifetimeFeature ( ) ) ;
508
508
httpContext . RequestServices = serviceCollection . BuildServiceProvider ( ) ;
509
509
510
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < Todo > ) TestAction ) ;
510
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < Todo > ) TestAction ) ;
511
511
512
512
await requestDelegate ( httpContext ) ;
513
513
@@ -543,7 +543,7 @@ void TestAction([FromBody] Todo todo)
543
543
httpContext . Features . Set < IHttpRequestLifetimeFeature > ( new TestHttpRequestLifetimeFeature ( ) ) ;
544
544
httpContext . RequestServices = serviceCollection . BuildServiceProvider ( ) ;
545
545
546
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < Todo > ) TestAction ) ;
546
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < Todo > ) TestAction ) ;
547
547
548
548
await requestDelegate ( httpContext ) ;
549
549
@@ -578,7 +578,7 @@ void TestAction([FromForm] int value)
578
578
var httpContext = new DefaultHttpContext ( ) ;
579
579
httpContext . Request . Form = form ;
580
580
581
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < int > ) TestAction ) ;
581
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < int > ) TestAction ) ;
582
582
583
583
await requestDelegate ( httpContext ) ;
584
584
@@ -608,7 +608,7 @@ void TestAction([FromForm] int value)
608
608
httpContext . Features . Set < IHttpRequestLifetimeFeature > ( new TestHttpRequestLifetimeFeature ( ) ) ;
609
609
httpContext . RequestServices = serviceCollection . BuildServiceProvider ( ) ;
610
610
611
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < int > ) TestAction ) ;
611
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < int > ) TestAction ) ;
612
612
613
613
await requestDelegate ( httpContext ) ;
614
614
@@ -644,7 +644,7 @@ void TestAction([FromForm] int value)
644
644
httpContext . Features . Set < IHttpRequestLifetimeFeature > ( new TestHttpRequestLifetimeFeature ( ) ) ;
645
645
httpContext . RequestServices = serviceCollection . BuildServiceProvider ( ) ;
646
646
647
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < int > ) TestAction ) ;
647
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < int > ) TestAction ) ;
648
648
649
649
await requestDelegate ( httpContext ) ;
650
650
@@ -664,16 +664,16 @@ public void BuildRequestDelegateThrowsInvalidOperationExceptionGivenBothFromBody
664
664
void TestAction ( [ FromBody ] int value1 , [ FromForm ] int value2 ) { }
665
665
void TestActionWithFlippedParams ( [ FromForm ] int value1 , [ FromBody ] int value2 ) { }
666
666
667
- Assert . Throws < InvalidOperationException > ( ( ) => RequestDelegateFactory . Build ( ( Action < int , int > ) TestAction ) ) ;
668
- Assert . Throws < InvalidOperationException > ( ( ) => RequestDelegateFactory . Build ( ( Action < int , int > ) TestActionWithFlippedParams ) ) ;
667
+ Assert . Throws < InvalidOperationException > ( ( ) => RequestDelegateFactory . Create ( ( Action < int , int > ) TestAction ) ) ;
668
+ Assert . Throws < InvalidOperationException > ( ( ) => RequestDelegateFactory . Create ( ( Action < int , int > ) TestActionWithFlippedParams ) ) ;
669
669
}
670
670
671
671
[ Fact ]
672
672
public void BuildRequestDelegateThrowsInvalidOperationExceptionGivenFromBodyOnMultipleParameters ( )
673
673
{
674
674
void TestAction ( [ FromBody ] int value1 , [ FromBody ] int value2 ) { }
675
675
676
- Assert . Throws < InvalidOperationException > ( ( ) => RequestDelegateFactory . Build ( ( Action < int , int > ) TestAction ) ) ;
676
+ Assert . Throws < InvalidOperationException > ( ( ) => RequestDelegateFactory . Create ( ( Action < int , int > ) TestAction ) ) ;
677
677
}
678
678
679
679
[ Fact ]
@@ -693,7 +693,7 @@ void TestAction([FromService] MyService myService)
693
693
var httpContext = new DefaultHttpContext ( ) ;
694
694
httpContext . RequestServices = serviceCollection . BuildServiceProvider ( ) ;
695
695
696
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < MyService > ) TestAction ) ;
696
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < MyService > ) TestAction ) ;
697
697
698
698
await requestDelegate ( httpContext ) ;
699
699
@@ -712,7 +712,7 @@ void TestAction(HttpContext httpContext)
712
712
713
713
var httpContext = new DefaultHttpContext ( ) ;
714
714
715
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < HttpContext > ) TestAction ) ;
715
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < HttpContext > ) TestAction ) ;
716
716
717
717
await requestDelegate ( httpContext ) ;
718
718
@@ -732,7 +732,7 @@ void TestAction(IFormCollection httpContext)
732
732
var httpContext = new DefaultHttpContext ( ) ;
733
733
httpContext . Request . Headers [ "Content-Type" ] = "application/x-www-form-urlencoded" ;
734
734
735
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < IFormCollection > ) TestAction ) ;
735
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < IFormCollection > ) TestAction ) ;
736
736
737
737
await requestDelegate ( httpContext ) ;
738
738
@@ -755,7 +755,7 @@ void TestAction(CancellationToken cancellationToken)
755
755
RequestAborted = cts . Token
756
756
} ;
757
757
758
- var requestDelegate = RequestDelegateFactory . Build ( ( Action < CancellationToken > ) TestAction ) ;
758
+ var requestDelegate = RequestDelegateFactory . Create ( ( Action < CancellationToken > ) TestAction ) ;
759
759
760
760
await requestDelegate ( httpContext ) ;
761
761
@@ -799,7 +799,7 @@ public async Task RequestDelegateWritesComplexReturnValueAsJsonResponseBody(Dele
799
799
var responseBodyStream = new MemoryStream ( ) ;
800
800
httpContext . Response . Body = responseBodyStream ;
801
801
802
- var requestDelegate = RequestDelegateFactory . Build ( @delegate ) ;
802
+ var requestDelegate = RequestDelegateFactory . Create ( @delegate ) ;
803
803
804
804
await requestDelegate ( httpContext ) ;
805
805
@@ -848,7 +848,7 @@ public async Task RequestDelegateUsesCustomIResult(Delegate @delegate)
848
848
var responseBodyStream = new MemoryStream ( ) ;
849
849
httpContext . Response . Body = responseBodyStream ;
850
850
851
- var requestDelegate = RequestDelegateFactory . Build ( @delegate ) ;
851
+ var requestDelegate = RequestDelegateFactory . Create ( @delegate ) ;
852
852
853
853
await requestDelegate ( httpContext ) ;
854
854
@@ -891,7 +891,7 @@ public async Task RequestDelegateWritesStringReturnValueAsJsonResponseBody(Deleg
891
891
var responseBodyStream = new MemoryStream ( ) ;
892
892
httpContext . Response . Body = responseBodyStream ;
893
893
894
- var requestDelegate = RequestDelegateFactory . Build ( @delegate ) ;
894
+ var requestDelegate = RequestDelegateFactory . Create ( @delegate ) ;
895
895
896
896
await requestDelegate ( httpContext ) ;
897
897
@@ -932,7 +932,7 @@ public async Task RequestDelegateWritesIntReturnValue(Delegate @delegate)
932
932
var responseBodyStream = new MemoryStream ( ) ;
933
933
httpContext . Response . Body = responseBodyStream ;
934
934
935
- var requestDelegate = RequestDelegateFactory . Build ( @delegate ) ;
935
+ var requestDelegate = RequestDelegateFactory . Create ( @delegate ) ;
936
936
937
937
await requestDelegate ( httpContext ) ;
938
938
@@ -973,7 +973,7 @@ public async Task RequestDelegateWritesBoolReturnValue(Delegate @delegate)
973
973
var responseBodyStream = new MemoryStream ( ) ;
974
974
httpContext . Response . Body = responseBodyStream ;
975
975
976
- var requestDelegate = RequestDelegateFactory . Build ( @delegate ) ;
976
+ var requestDelegate = RequestDelegateFactory . Create ( @delegate ) ;
977
977
978
978
await requestDelegate ( httpContext ) ;
979
979
0 commit comments