Class ProtoWireMockClient
One fake HTTP service for the running test: stub routes that read like the scenario, the base URL to point the system under test at, and the requests the fake served. The fake starts on the first call that needs it; a per-test fake stops with the test, a per-run fake keeps serving with its stubs and log until the run releases it.
public sealed class ProtoWireMockClient
- Inheritance
-
ProtoWireMockClient
- Inherited Members
- Extension Methods
Properties
BaseUrl
The base URL the fake listens on, without a trailing slash.
public string BaseUrl { get; }
Property Value
Name
The fake's name, as registered with AddWireMock.
public string Name { get; }
Property Value
Port
The port the fake listens on.
public int Port { get; }
Property Value
ReceivedRequests
Gets every request the fake served, oldest first.
public IReadOnlyList<ProtoWireMockRequest> ReceivedRequests { get; }
Property Value
Server
The running WireMock server, for matchers the facade does not cover. Requests it serves are still observed in the trace, with their concrete path as the identifier.
public WireMockServer Server { get; }
Property Value
UnmatchedRequests
Gets the requests no stub matched, oldest first.
public IReadOnlyList<ProtoWireMockRequest> UnmatchedRequests { get; }
Property Value
Methods
Given(IRequestMatcher)
Registers a raw WireMock matcher the facade does not cover. The match is still observed in the trace, but without a route template the identifier is the concrete request path.
public IRespondWithAProvider Given(IRequestMatcher matcher)
Parameters
matcherIRequestMatcher
Returns
Reset()
Clears the stubs and the request log now, instead of waiting for the run's release.
public void Reset()
Stub(HttpMethod, string)
Declares a stub the fake serves: the method and path template requests must match. Paths follow
the WireMock path syntax, where * matches a segment. The stub serves nothing until a
response is set on it; registering it records the stub for coverage immediately.
public ProtoWireMockStub Stub(HttpMethod method, string path)
Parameters
methodHttpMethodpathstring
Returns
Stub(string, string)
Declares a stub the fake serves: the method and path template requests must match. Paths follow
the WireMock path syntax, where * matches a segment. The stub serves nothing until a
response is set on it; registering it records the stub for coverage immediately.
public ProtoWireMockStub Stub(string method, string path)
Parameters
Returns
VerifyNoUnmatchedRequests()
Fails naming the fake and every unmatched request when the fake served one. Call it at the end of a test that must only hit stubbed routes.
public void VerifyNoUnmatchedRequests()