Add Tests for REST endpoints

Issue #758 resolved
Brian Lewis repo owner created an issue

We can now manually use the resttest route in the client app to manually test rest endpoints, at least those using GET.

This work shows a proof of concept os incorporating more generally rest tests into the Visual Studio testing framework, specifically into the project Pineapples.Data.Tests.

Interaction with the Rest api is via the HttpClient object.

The samples built show:

  • a login process to extract the bear_token, that may then be used on subsequent calls
  • a simple GET (api/schools/CHK001)
  • a post (api/schools/collection/filter)

Key in all this is moving between C# objects and Json (in both directions) to set up parameters to a REST call, and to retrieve the results.

There is a complication in testing in that you cannot run tests from the test explorer while the project is running - but there is no API if the project is not running!

Solution seems to be to use Debug-> Start Without Debugging to get IIS started; then you can run tests against it and get a response.

Currently a username and password for login are read from Pineapples.Data.Tests/app.config - don;t leave any real logins in here.

A lot of work to do to test every endpoint, but we can begin with:

  • simple reads of basic objects
  • filter reads
  • warehouse endpoints

Comments (1)

  1. Log in to comment