How can I call InitHccApp() outside of the web context?

This is a common issue across any web application's server-side API.  When the web application's API was written and intended for having an HTTP context, challenges will be created.  Unfortunately, this is the case here, which is part of the reason the REST API exists.  It's missing a handful of things and isn't as convenient for some though.  

Even we run into this challenge internally with our manual and automated test suites.  However, we have a workaround that may work for you.  In our tests, we generate the Hotcakes Application context manually, either using an external data source, or using the known store ID.  

In the example below, you'll see that the HccApp object is getting initiated using a hard-coded store ID.

public static HotcakesApplication CreateHccAppInMemory()
    HccAppHelper.IsForMemoryOnly = true;
    var hccApp = HccAppHelper.InitHccApp(true);
    hccApp.CurrentStore = new Store { Id = 1 };
    return hccApp;
Have more questions? Submit a request

Need More Help?

Do you need more assistance with this article? Please review your support options.