@@ -150,5 +150,75 @@ public void ParseEmptyOrNullQueryWorks(string queryString)
150
150
151
151
Assert . Empty ( queryCollection ) ;
152
152
}
153
+
154
+ [ Fact ]
155
+ public void ParseQueryWithEncodedKeyWorks ( )
156
+ {
157
+ var features = new FeatureCollection ( ) ;
158
+ features [ typeof ( IHttpRequestFeature ) ] = new HttpRequestFeature { QueryString = "?fields+%5BtodoItems%5D" } ;
159
+
160
+ var provider = new QueryFeature ( features ) ;
161
+
162
+ var queryCollection = provider . Query ;
163
+
164
+ Assert . Single ( queryCollection ) ;
165
+ Assert . Equal ( "" , queryCollection [ "fields [todoItems]" ] . FirstOrDefault ( ) ) ;
166
+ }
167
+
168
+ [ Fact ]
169
+ public void ParseQueryWithEncodedValueWorks ( )
170
+ {
171
+ var features = new FeatureCollection ( ) ;
172
+ features [ typeof ( IHttpRequestFeature ) ] = new HttpRequestFeature { QueryString = "?=fields+%5BtodoItems%5D" } ;
173
+
174
+ var provider = new QueryFeature ( features ) ;
175
+
176
+ var queryCollection = provider . Query ;
177
+
178
+ Assert . Single ( queryCollection ) ;
179
+ Assert . Equal ( "fields [todoItems]" , queryCollection [ "" ] . FirstOrDefault ( ) ) ;
180
+ }
181
+
182
+ [ Fact ]
183
+ public void ParseQueryWithEncodedKeyEmptyValueWorks ( )
184
+ {
185
+ var features = new FeatureCollection ( ) ;
186
+ features [ typeof ( IHttpRequestFeature ) ] = new HttpRequestFeature { QueryString = "?fields+%5BtodoItems%5D=" } ;
187
+
188
+ var provider = new QueryFeature ( features ) ;
189
+
190
+ var queryCollection = provider . Query ;
191
+
192
+ Assert . Single ( queryCollection ) ;
193
+ Assert . Equal ( "" , queryCollection [ "fields [todoItems]" ] . FirstOrDefault ( ) ) ;
194
+ }
195
+
196
+ [ Fact ]
197
+ public void ParseQueryWithEncodedKeyEncodedValueWorks ( )
198
+ {
199
+ var features = new FeatureCollection ( ) ;
200
+ features [ typeof ( IHttpRequestFeature ) ] = new HttpRequestFeature { QueryString = "?fields+%5BtodoItems%5D=%5B+1+%5D" } ;
201
+
202
+ var provider = new QueryFeature ( features ) ;
203
+
204
+ var queryCollection = provider . Query ;
205
+
206
+ Assert . Single ( queryCollection ) ;
207
+ Assert . Equal ( "[ 1 ]" , queryCollection [ "fields [todoItems]" ] . FirstOrDefault ( ) ) ;
208
+ }
209
+
210
+ [ Fact ]
211
+ public void ParseQueryWithEncodedKeyEncodedValuesWorks ( )
212
+ {
213
+ var features = new FeatureCollection ( ) ;
214
+ features [ typeof ( IHttpRequestFeature ) ] = new HttpRequestFeature { QueryString = "?fields+%5BtodoItems%5D=%5B+1+%5D&fields+%5BtodoItems%5D=%5B+2+%5D" } ;
215
+
216
+ var provider = new QueryFeature ( features ) ;
217
+
218
+ var queryCollection = provider . Query ;
219
+
220
+ Assert . Single ( queryCollection ) ;
221
+ Assert . Equal ( new [ ] { "[ 1 ]" , "[ 2 ]" } , queryCollection [ "fields [todoItems]" ] ) ;
222
+ }
153
223
}
154
224
}
0 commit comments