Game Development Reference
In-Depth Information
Testing with the simulator
Much of what we have looked at uses the CurrentApp class, which connects to the
associated Windows Store account to process the transactions. This requires that any
IAP products exist in the dashboard, and really gets in the way of any sort of testing
before you submit your game. To get around this, the CurrentAppSimulator class
allows us to test the different scenarios to ensure that our trial mode and the IAP code
work fine. The simulator also allows you to test without even creating the app in the
store dashboard, instead using a local XML file that describes the game and any IAP
products that can be sold to populate the different listings and license details.
To get started with this, we need to replace all instances of the CurrentApp class
with the CurrentAppSimulator . This can be easily accomplished using a prepro-
cessor directive for DEBUG builds, and some typedefs to abstract the CurrentApp
and CurrentAppSimulator based on the build configuration.
#if DEBUG
typedef
Windows::ApplicationModel::Store::CurrentAppSimulator
StoreApp;
#else
typedef
Windows::ApplicationModel::Store::CurrentApp
StoreApp;
#endif
In this case we rename the object to StoreApp , and let the preprocessor handle
choosing the correct class to use.
Now we need to load in the XML file that describes our simulation product(s). Where
you choose to include this XML file is up to you however, the simplest place is to in-
clude it in the build until you're ready to submit your game, and then remove it before
doing so.
To load the file, we need to manually load the StorageFile that represents it.
If you're looking to retrieve from the app package, you can do so using the
Windows::ApplicationModel::Package::Current->InstalledLocation ,
Search WWH ::




Custom Search