WhenContext: Making Calls - LiberatorTestTools/RESTore GitHub Wiki
Once the GivenContext has been set, we move to the setup of the WhenContext with a simple call:
.When()
Many HTTP endpoints contain parameter values within their path, such as IDs of target entities to which the call applies. RESTore contains the PathParameter method to change the values within the path. These should be specified before the call is specified, as the use of the GET, PUT, POST etc. calls will move away from the WhenContext and begin the execution of the call.
.PathParameter("id", "value")
.PathParameter(pathDictionary)
e.g., a path /api/v1/company/{id}/details => /api/v1/company/317/details.
We can also specify that we want a primitive load test to run. This functionality is subject of a current development project and will be enhanced soon. For now, the primitive version remains:
.LoadTest(users, duration)
Finally, we can select the type of call we are about to make. The URI value in each of these cases is only required if the URI has not been set in the GivenContext.
.Get("route/to/end/point")
.Post("route/to/end/point")
.Put("route/to/end/point")
.Patch("route/to/end/point")
.Delete("route/to/end/point")
At this point, the call is executed (calling the ExecutionContext). Assuming that we require validation on the call, we close the previous context by calling the ThenContext:
.Then()