Class MockOptions

Namespace
Kuestenlogik.Bowire.Mock
Assembly
Kuestenlogik.Bowire.Mock.dll

Tunables for MapBowireMock in embedded (middleware) mode.

public sealed class MockOptions
Inheritance
MockOptions
Inherited Members

Constructors

MockOptions()

public MockOptions()

Properties

CaptureMissPath

When set, unmatched REST requests are appended as placeholder steps to the named file (Phase 3c). Use this to turn an exercised mock into the seed of a new recording — run the client, collect the misses, fill in the missing responses. null disables capture (default). gRPC misses are skipped because their binary bodies can't be faithfully captured as text.

public string? CaptureMissPath { get; set; }

Property Value

string

Chaos

Chaos-injection tunables — latency jitter and fail-rate applied before dispatch to the replayer (Phase 3a). Defaults are off.

public ChaosOptions Chaos { get; set; }

Property Value

ChaosOptions

ControlToken

Shared secret for the runtime scenario-switch control endpoint (POST /__bowire/mock/scenario). When null (default) the control endpoints return 404 — not advertised, not reachable. When set, the endpoint compares the value against the X-Bowire-Mock-Token header and responds 401 on a mismatch. Pick a non-trivial value even in dev; a compromised CI pipeline shouldn't be able to re-point the mock at arbitrary files on the host.

public string? ControlToken { get; set; }

Property Value

string

Faults

Per-method fault-injection rules (#170) — latency distributions, error rates, partial responses, connection drops. Evaluated after Chaos on matched steps. Defaults to an empty set (off).

public FaultRuleSet Faults { get; set; }

Property Value

FaultRuleSet

Logger

Optional logger for the middleware. When null, the middleware resolves one from the request's IServiceProvider.

public ILogger? Logger { get; set; }

Property Value

ILogger

Loop

When true, proactive emitters (the built-in MQTT one and plugin-contributed ones) replay their step sequence on repeat. Propagated from Loop so emitters don't have to reach into the outer server options to learn it. Has no effect on request-driven replay paths.

public bool Loop { get; set; }

Property Value

bool

Matcher

Matcher used to pair incoming requests with recorded steps. Defaults to ExactMatcher; replace with a Phase-2 path / topic matcher once those ship.

public IMockMatcher Matcher { get; set; }

Property Value

IMockMatcher

PassThroughOnMiss

When true (default), incoming requests that don't match any recorded step fall through to the rest of the ASP.NET pipeline. Set to false to return 404 on a miss — useful when the mock is meant to be the only responder for this route prefix.

public bool PassThroughOnMiss { get; set; }

Property Value

bool

ProxyBaseUrl

#407: base URL of a real upstream to forward unmatched requests to (WireMock's proxyBaseUrl) — enables partial mocking: mock the stubs you have, proxy everything else to the live service. The target is fixed by this config (never taken from the request), so the mock can't be turned into an open relay. A matched stub can also opt into proxying via Proxy. Null = no proxy.

public string? ProxyBaseUrl { get; set; }

Property Value

string

ProxyHttpClient

#407: optional HttpClient used for proxy forwarding. Injectable for embedded hosts / tests; defaults to a shared reusable client (the recommended HttpClient pattern) when null.

public HttpClient? ProxyHttpClient { get; set; }

Property Value

HttpClient

ProxyRecordPath

#430 (record-through): when set alongside a proxy (ProxyBaseUrl or a per-stub proxy), each proxied response is appended as a stub to this recording file — capture-by-proxy, so a later run replays it. Null = forward only, don't persist.

public string? ProxyRecordPath { get; set; }

Property Value

string

RecordingDirectory

#406: base directory for resolving a stub's bodyFileName (ResponseBodyFile). Set automatically from the recording file's directory by UseBowireMock(path, …); null for in-memory recordings (absolute paths only).

public string? RecordingDirectory { get; set; }

Property Value

string

ReplaySpeed

Speed multiplier for streaming replay (Phase 2c onwards). 1.0 preserves the original cadence captured on the per-frame timestampMs; 2.0 is twice as fast; 0 emits every frame immediately. Non-positive values other than 0 are treated as 0.

public double ReplaySpeed { get; set; }

Property Value

double

RequestObserver

Optional sink that receives one MockRequestEntry per request after the response is written (#57). The workbench- driven mock registry wires a bounded MockRequestLog here; embedded hosts that don't care leave it null. The observer's OnRequest(MockRequestEntry) is invoked from a OnCompleted(Func<Task>) callback, so it runs out of the request hot path and exceptions it throws never bubble back to the client.

public IMockRequestObserver? RequestObserver { get; set; }

Property Value

IMockRequestObserver

ResponseTransformer

#406: response-transformer extension point. Invoked with the request context and the final REST body (after placeholder substitution) to return a possibly-mutated body — the analog of WireMock's ResponseDefinitionTransformer. Null = no transform.

public Func<HttpContext, string, string>? ResponseTransformer { get; set; }

Property Value

Func<HttpContext, string, string>

Select

Optional recording name or id — disambiguates a file that contains multiple recordings (e.g. the full ~/.bowire/recordings.json store). Ignored when the file contains a single recording.

public string? Select { get; set; }

Property Value

string

Stateful

When true, the mock advances through the recording's steps in order — only the step at the current cursor position is eligible to match, step N+1 can only reply after step N has been hit (Phase 3b). Defaults to false (stateless — any step may match any time). Pairs with StatefulWrapAround for end-of-recording behaviour.

public bool Stateful { get; set; }

Property Value

bool

StatefulWrapAround

When Stateful is on and the cursor has advanced past the last step, true (default) wraps back to step 0 so the recording loops; false returns the configured miss (PassThroughOnMiss) for every subsequent request.

public bool StatefulWrapAround { get; set; }

Property Value

bool

Watch

When true (default), the recording file is watched with RecordingWatcher and reloaded on change. Tests usually want this off to avoid reload-vs-assert races.

public bool Watch { get; set; }

Property Value

bool

Methods

ForEmitter()

Project this full options bag down to the slim MockEmitterOptions shape that plugin-contributed emitters consume. The server-only knobs (matchers, chaos, stateful cursor, control-token, miss-capture path) don't apply to proactive emitters and are deliberately excluded so plugins never have to reason about them.

public MockEmitterOptions ForEmitter()

Returns

MockEmitterOptions