Class ProtoWireMockStub

Namespace
ProtoTest.WireMock
Assembly
ProtoTest.WireMock.dll

One stub on a fake: the method and path template it serves and the response it serves with. The first response call registers the WireMock mapping; a later one replaces it, so re-stubbing never stacks two mappings for one stub. Paths follow the WireMock path syntax, where * matches a segment.

public sealed class ProtoWireMockStub
Inheritance
ProtoWireMockStub
Inherited Members
Extension Methods

Properties

Identifier

Gets the stub's route identifier, the same shape the trace and coverage use.

public string Identifier { get; }

Property Value

string

Method

The HTTP method the stub serves, upper-cased.

public string Method { get; }

Property Value

string

Path

The path template the stub serves, as registered.

public string Path { get; }

Property Value

string

ReceivedCount

Gets how many requests this stub served; zero before the first response is set.

public int ReceivedCount { get; }

Property Value

int

StatusCode

Gets the status the stub currently serves, or null before the first response is set.

public int? StatusCode { get; }

Property Value

int?

Methods

RespondJson(HttpStatusCode, object)

Serves a JSON body with the status.

public ProtoWireMockStub RespondJson(HttpStatusCode statusCode, object body)

Parameters

statusCode HttpStatusCode
body object

Returns

ProtoWireMockStub

RespondWith(HttpStatusCode)

Serves an empty body with the status.

public ProtoWireMockStub RespondWith(HttpStatusCode statusCode)

Parameters

statusCode HttpStatusCode

Returns

ProtoWireMockStub

RespondWith(HttpStatusCode, string, string)

Serves a raw body with the status and media type.

public ProtoWireMockStub RespondWith(HttpStatusCode statusCode, string body, string mediaType)

Parameters

statusCode HttpStatusCode
body string
mediaType string

Returns

ProtoWireMockStub

VerifyHappened()

Fails naming the stub when it served no request.

public ProtoWireMockStub VerifyHappened()

Returns

ProtoWireMockStub

VerifyHappened(int)

Fails naming the stub when it did not serve exactly times requests.

public ProtoWireMockStub VerifyHappened(int times)

Parameters

times int

Returns

ProtoWireMockStub

VerifyHappenedOnce()

Fails naming the stub when it did not serve exactly one request.

public ProtoWireMockStub VerifyHappenedOnce()

Returns

ProtoWireMockStub

WithHeader(string, params string[])

Adds a response header to what the stub serves, replacing the mapping it registered.

public ProtoWireMockStub WithHeader(string name, params string[] values)

Parameters

name string
values string[]

Returns

ProtoWireMockStub