Class ProtoWireMockClient

Namespace
ProtoTest.WireMock
Assembly
ProtoTest.WireMock.dll

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

string

Name

The fake's name, as registered with AddWireMock.

public string Name { get; }

Property Value

string

Port

The port the fake listens on.

public int Port { get; }

Property Value

int

ReceivedRequests

Gets every request the fake served, oldest first.

public IReadOnlyList<ProtoWireMockRequest> ReceivedRequests { get; }

Property Value

IReadOnlyList<ProtoWireMockRequest>

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

WireMockServer

UnmatchedRequests

Gets the requests no stub matched, oldest first.

public IReadOnlyList<ProtoWireMockRequest> UnmatchedRequests { get; }

Property Value

IReadOnlyList<ProtoWireMockRequest>

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

matcher IRequestMatcher

Returns

IRespondWithAProvider

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

method HttpMethod
path string

Returns

ProtoWireMockStub

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

method string
path string

Returns

ProtoWireMockStub

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()