Day 1: Fake Implementation
Objective for Day 1
Create a fully working implementation of the Open Booking API by using FakeDatabase within your application.
Rationale
Having a fully working implementation allows you to easily see what needs to be achieved, and also provides an easy way to ensure that the test suite and libraries are behaving as expected within your environment.
Step 1 - Copy files
Copy the files within the Feeds, Helpers, IdComponents, Settings, and Stores directories from the example project into your application, and add the dependencies OpenActive.Server.NET and OpenActive.FakeDatabase.NET. FakeDatabase.NET is an in-memory fake database that is not persisted, and will allow you to create a quick working Open Booking API.
Inspect the Controllers and copy the files (or the contents of the files) as appropriate for your application.
Note you will be creating the following endpoints (as per the Open Booking API specification):
Dataset Site
Open Data RPDE feeds
OrderQuote Creation (C1)
OrderQuote Creation (C2)
OrderQuote Deletion
Order Creation (B)
Order Deletion
Order Cancellation
Orders RPDE Feed
Order Status
Additionally you will be creating three endpoints for use with the OpenActive Test Suite that implement the Open Booking API Test Interface (not for use in production):
Delete Test Dataset
Create Test Opportunity
Execute Action
A further endpoint is required to meet the recommendations outlined for authentication, however this can be added as part of Day 8 as it has it is not a dependency of Days 1-7:
Dynamic Client Update
Step 2 - Copy configuration
Inspect the Startup.cs (.NET Core) or ServiceConfig.cs (.NET Framework) and copy the services.AddSingleton<IBookingEngine>(...) configuration into your own Startup.cs or ServiceConfig.cs.
The initial objective is to get a working version of the Open Booking API using entirely fake data. So when copying these files do not modify the configuration values at this stage - simply use them as-is.
Step 2 - Controller endpoint bindings
The ResponseContent class provides a .NET version agnostic representation of HTTP responses from the Booking Engine. Two example helper methods are provided to be used with your version of .NET. See ResponseContentHelper.csin the example projects.
.NET Core
The following extension method can be used to return an Mvc.ContentResult.
.NET Framework
The following extension method can be used to return an HttpResponseMessage.
Step 3 - Input Formatter
The Booking Engine accepts input JSON as string in order to fully control deserialisation. In order to allow the web framework to capture the body of the request as a string, for the Open Booking API's media type, an InputFormatter is required. See OpenBookingInputFormatter.csin the example projects.
.NET Core
.NET Framework
Step 4 - Authentication Helper
The Booking Engine does not handle authentication, and instead accepts claims from an authentication layer in front of it (this will be covered in more detail in Day 8). An AuthenticationHelper is provided for .NET Core and .NET Framework that extracts OAuth 2.0 claims from access tokens, and also provides simple header alternatives to facilitate development and testing.
Note that these test header alternatives are not secure and must not be used in production, however they will be used for Day 1-7 of this guide.
.NET Core
.NET Core implementations can leverage the authentication middleware, using the provided helpers:
To speed development, the following allows test headers to be used for accessing the API, and can be set up to allow development to proceed until Day 8 of this tutorial.
.NET Framework
Step 5 - Run Application
If you run your application and navigate to the dataset site endpoint (e.g. https://localhost:44307/openactive), you should find the following page:

Clicking on the ScheduledSessions feed should return JSON in the following format:

If some links appear broken, try updating BaseUrl within Startup.cs or ServiceConfig.cs with the correct port number for your local test environment.
Navigating to the Orders feed (e.g. https://localhost:44307/api/openbooking/orders-rpde) should return the following JSON result (an empty RPDE page):

Step 6 - Run Test Suite
The Booking Engine includes full support for the Open Booking API Test Interface, so running the OpenActive Test Suite in 'Controlled' mode is recommended.
Follow the instructions below to set up the OpenActive Test Suite:
You will need Node.js version 14 or above installed to do this - which can installed with the Visual Studio installer.
In Steps 7 and 8, the header configuration can use the default values in order to work with the Booking Engine, except that the Seller @id must be replaced with a valid Seller @id from your booking system.
In Step 9, your Dataset Site is automatically created and configured by the Booking Engine, so simply update the value of datasetSiteUrl based on the port number and path used by your .NET application when running:
At this stage we are still using FakeDatabase, so all tests for whichever 'implemented' features you have configured should pass. Assuming configuration values have not been changed from the copied files, issues with the tests at this stage will very likely be due to the controller or other application configuration.
Last updated
Was this helpful?