@@ -1022,6 +1022,33 @@ public void BuildRequestDelegateThrowsInvalidOperationExceptionForInvalidParamet
1022
1022
Assert . Equal ( errorMessage , exception . Message ) ;
1023
1023
}
1024
1024
1025
+ public static object [ ] [ ] BadArgumentEnumerableActions
1026
+ {
1027
+ get
1028
+ {
1029
+ void TestParameterStringList ( [ AsParameters ] List < string > req ) { }
1030
+ void TestParameterDictionary ( [ AsParameters ] Dictionary < string , string > req ) { }
1031
+ void TestParameterIntArray ( [ AsParameters ] int [ ] req ) { }
1032
+
1033
+ return new object [ ] [ ]
1034
+ {
1035
+ new object [ ] { ( Action < List < string > > ) TestParameterStringList } ,
1036
+ new object [ ] { ( Action < Dictionary < string , string > > ) TestParameterDictionary } ,
1037
+ new object [ ] { ( Action < int [ ] > ) TestParameterIntArray }
1038
+ } ;
1039
+ }
1040
+ }
1041
+
1042
+ [ Theory ]
1043
+ [ MemberData ( nameof ( BadArgumentEnumerableActions ) ) ]
1044
+ public void BuildRequestDelegateThrowsNotSupportedExceptionForEnumerable ( Delegate @delegate )
1045
+ {
1046
+ var errorMessage = $ "The { nameof ( AsParametersAttribute ) } is not supported on enumerable parameters.";
1047
+ var exception = Assert . Throws < NotSupportedException > ( ( ) => RequestDelegateFactory . Create ( @delegate ) ) ;
1048
+
1049
+ Assert . Equal ( errorMessage , exception . Message ) ;
1050
+ }
1051
+
1025
1052
[ Fact ]
1026
1053
public void BuildRequestDelegateThrowsNotSupportedExceptionForNestedParametersList ( )
1027
1054
{
@@ -2014,6 +2041,15 @@ void TestJsonAndFormWithAttribute(Todo value1, [FromForm] string value2) { }
2014
2041
Assert . Throws < InvalidOperationException > ( ( ) => RequestDelegateFactory . Create ( TestJsonAndFormWithAttribute ) ) ;
2015
2042
}
2016
2043
2044
+ [ Fact ]
2045
+ public void CreateThrowsInvalidOperationExceptionIfIFormFileCollectionHasAsParametersAttribute ( )
2046
+ {
2047
+ void TestAction ( [ AsParameters ] IFormFileCollection formFiles ) { }
2048
+
2049
+ var ioe = Assert . Throws < InvalidOperationException > ( ( ) => RequestDelegateFactory . Create ( TestAction ) ) ;
2050
+ Assert . Equal ( "The abstract type 'IFormFileCollection' is not supported." , ioe . Message ) ;
2051
+ }
2052
+
2017
2053
[ Fact ]
2018
2054
public void CreateThrowsNotSupportedExceptionIfIFormFileCollectionHasMetadataParameterName ( )
2019
2055
{
0 commit comments