I was unit testing my Get query provided by AutoQuery feature of service stack.
Below is the code of test-
var testABCQueryService = new ABCQueryService();
testABCQueryService.Request = new MockHttpRequest(“ABCDto”, “GET”, “”, “/ABC/”, new NameValueCollection(), new MemoryStream(), new NameValueCollection());
testABCQueryService.AutoQuery = new ServiceStack.AutoQuery();
var result = testABCQueryService.Get(new ABCDto());
I am using this structure of code to test as we have below format of code for Get operation-
public QueryResponse Get(ABCDto req)
However, while executing ExecuteSimpleQuery(req) method, exception is thrown at below line of code-
if (queryArgs == null) queryArgs = Request.GetRequestParams();
var q = AutoQuery.CreateQuery(req, queryArgs, Request);
May I know, root cause of the exception here ? And any workaround/code ?
Note: I have seen examples of integration testing for servicestack from your forum where Get method is explicitly called using Base URi like-
string BaseUri = “http://Dev:2000/”;
var client = new JsonServiceClient(BaseUri);
var xyz = client.Get(new ABCDto());
However, it does not fit to our architecture, hence I am using above mentioned format of code.