Class ProtoWireMockStub
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
Method
The HTTP method the stub serves, upper-cased.
public string Method { get; }
Property Value
Path
The path template the stub serves, as registered.
public string Path { get; }
Property Value
ReceivedCount
Gets how many requests this stub served; zero before the first response is set.
public int ReceivedCount { get; }
Property Value
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
statusCodeHttpStatusCodebodyobject
Returns
RespondWith(HttpStatusCode)
Serves an empty body with the status.
public ProtoWireMockStub RespondWith(HttpStatusCode statusCode)
Parameters
statusCodeHttpStatusCode
Returns
RespondWith(HttpStatusCode, string, string)
Serves a raw body with the status and media type.
public ProtoWireMockStub RespondWith(HttpStatusCode statusCode, string body, string mediaType)
Parameters
statusCodeHttpStatusCodebodystringmediaTypestring
Returns
VerifyHappened()
Fails naming the stub when it served no request.
public ProtoWireMockStub VerifyHappened()
Returns
VerifyHappened(int)
Fails naming the stub when it did not serve exactly times requests.
public ProtoWireMockStub VerifyHappened(int times)
Parameters
timesint
Returns
VerifyHappenedOnce()
Fails naming the stub when it did not serve exactly one request.
public ProtoWireMockStub VerifyHappenedOnce()
Returns
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)