Nearly every Platform application contains a user interface of some type. The Platform natively manages the deployment of your ASP.NET-based websites onto the Platform. This page discusses ASP.NET websites that will be ultimately deployed onto the Platform instance. Note that accessing Apprenda services remotely from a “non-Apprenda” desktop (or some other) client is possible, but is not discussed in this topic.
Running websites locally on the Platform has special requirements because your application must be aware of multi-tenancy concerns, yet is not running on an environment where multi-tenancy concerns apply. A mocking environment, accessible via the Local API, is supplied for this purpose.
The Platform handles certain concerns shared by all multi-tenant applications, including Authentication and Authorization. In other words, before a User even is permitted to enter your application, he or she already must have logged in securely to establish a session and the Platform has already verified that the User has a subscription to the application.
Developers, however, need a way to simulate a User’s subscription when running the application locally in order to properly test the application. The Platform installs a special Windows service with the Apprenda SDK called the Apprenda Local API Host. With this service, a mocking environment that simulates Platform behavior becomes available and the Developer can connect into the backing host to simulate a Platform session.
The mock framework relies on defining a “mock context scope” via a special XML definition file. Through this environment, an individual working on the code can create various scenarios by setting up Tenant information, metering placeholders, and runtime expectations. When the code is launched for local testing, the API will use the local mock data and produce results equivalent to those that the application would experience in a deployed version. This local development style is much preferred to an online sandbox environment since it allows for more fluid code and test cycling.
A utility called the Apprenda Mocker is installed with the SDK to assist in editing these files. It can also be used to change the behavior of your application without re-starting your code.
To reference the mocking environment, there are two required steps:
If you create your website via the Apprenda Interface template installed in Visual Studio with the SDK, this is done automatically.
First, include the file that represents the backing data that you wish to use. By default, the mock framework will search for the Apprenda.mock.xml file in the executable directory. As part of SDK installation, Apprenda has posted the Apprenda configuration file XML schema to the target computer’s Visual Studio installation directory as well as a sample Apprenda configuration file which can be found in the SDK installation directory. It is also possible to use the Apprenda Mocker tool installed with the SDK to edit the backing data.
Second, include Apprenda’s modules in your UI’s configuration file. This will cause Apprenda to load contextual information based on the data supplied by the mock framework, which is derived from the Apprenda.mock.xml file.
<httpModules> <add name="ContextInitModule" type="Apprenda.SaaSGrid.API.Local.ContextInitModule, SaaSGrid.API.Local"/> <add name="ContextDisposeModule" type="Apprenda.SaaSGrid.API.Local.ContextDisposeModule, SaaSGrid.API.Local"/> </httpModules>
The value for configFile above should be a standard Windows file path.
If a user of the API would like the mock framework to use a different file, they should simply add the following to their App.config file:
<configSections> <section name="saaSGridLocal" type="System.Configuration.AppSettingsSection" /> </configSections> <saaSGridLocal> <add key="configFile" value="disk(\)::driveletter:@\Path\to\file.mock.xml"/> </saaSGridLocal>
The Apprenda Mocker can be used to load the Apprenda.mock.xml file (or other specified file) included with the application, where changes can then be made and “pushed” back to the application. This gives Users the ability to use a visual means to change the backing environment that the application is using without having to restart it.