LittleMissMe
New Member
The first line of my ApiController HttpGet action is this\[code\]var returnOnlyDefault = (Request.GetQueryNameValuePairs() .Any(kv => ((kv.Key.ToLower() == "defaultview") && (kv.Value.ToLower() == "true"))));\[/code\]This looks for a query string value of "defaultview". The code 'works', but i'm having trouble unit testing it.In my unit test i am doing the following\[code\]var controller = new Controllers.ViewsController { Request = new HttpRequestMessage() };controller.Request.Properties.Add(new KeyValuePair<string, object>("defaultview", "true"));\[/code\]the request uri is null of course. The test is failing as it doesn't pick up the query string value.