Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.

Expectations

Andrei Salanoi edited this page Jul 22, 2017 · 3 revisions

At the moment StoryLine.Rest library contains one expectation which is named HttpResponse. This expectation search for request added to actor's artifact collection by HttpRequest action. Once matching request is found expectations are evaluated against this response.

NOTE: Each response store reference to request used to sent it. This how later this response can be found to properties which are applied to request only.

The following methods are used to find response which needs to be used for validation:

  • Service() searches for matching response by service which it was sent to.
  • Url() matches response by url used to send request to.
  • Method() matches response by HTTP method of corresponding request.

NOTE: If request matching search criteria was not found exception is thrown.

The following configuration methods are used to define expectations:

  • Status() validates that response HTTP status code matches provided parameter.
  • ReasonPhrase() validates that status reason is exact match of provided value.
  • Header() validates that response contains header matching specific predicate. If specified header is not found exception is thrown.
  • RequestExpectation() this method accepts implementation of IResponseExpectation. It's expected to be used to support scenarios with custom expectations.

The following extension methods can be used to write body expectations:

  • JsonBody() verifies that response body is JSON document which matches provided predicates.
  • TextBody() verifies that response body is TEXT document which matches provided predicates.
Clone this wiki locally