AutoQuery throws "object ref. not set" error

Hi,

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());
Assert.That(result.Results.Count, Is.GreaterThan(0));

I am using this structure of code to test as we have below format of code for Get operation-
public QueryResponse Get(ABCDto req)
{
return ExecuteSimpleQuery(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.

Most functionality requires at least an AppHost configured, see the unit test docs for an example
http://docs.servicestack.net/testing#test-setup

Thanks for your quick response…!!
I have configured appHost as mentioned in document.
Only diff. between my test and documentation is that, it is using “:inmemory” in document, while I am using SQL for test DB, which work fine for “Create”, “Update” & “Delete” operations.