JasperFx / alba

Easy integration testing for ASP.NET Core applications
https://jasperfx.github.io/alba
Apache License 2.0
406 stars 39 forks source link

HttpContext.Request.QueryString does not support passing arrays as parameters #58

Closed theamazingfedex closed 6 years ago

theamazingfedex commented 6 years ago

Currently unable to send an array of items on a query string. Calling _.Get.Url("/endpoint").QueryString("relatedCustomerIds", 123).QueryString("relatedCustomerIds", 456) causes only relatedCustomerIds=456 to be appended to the resultant url. This problem could be solved by allowing multiple values per-key, or simply not manipulating the url to split query parameters into the HttpContext.Request.QueryString dictionary.

https://github.com/JasperFx/alba/blob/8f74b9c45420f900a9277a071bfc376be187c6d4/src/Alba/HttpContextExtensions.cs#L24 ^is the where the change would need to be made.

theamazingfedex commented 6 years ago

I ended up getting it to work by using:

_.Get.Url("/endpoint")
  .QueryString("relatedCustomerIds[0]", 123)
  .QueryString("relatedCustomerIds[1]", 456)

We are currently investigating a way to add lists like these to the query string without specifying the array indices using HttpContext.Request.QueryString.Create(IEnumerable<KeyValuePair<string,StringValues>>);