Class MockHandler

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

Per-pipeline handler that owns the currently-active recording and replays matching unary steps. Created once by UseBowireMock and shared across every request on the pipeline — the recording reference is swapped atomically by the file watcher on hot-reload.

public sealed class MockHandler
Inheritance
MockHandler
Inherited Members

Constructors

MockHandler(BowireRecording, MockOptions, ILogger, string?)

public MockHandler(BowireRecording recording, MockOptions options, ILogger logger, string? recordingPath = null)

Parameters

recording BowireRecording
options MockOptions
logger ILogger
recordingPath string

Methods

AddStub(BowireRecordingStep)

Append a stub (assigning an id when it has none). Returns the stored stub.

public BowireRecordingStep AddStub(BowireRecordingStep stub)

Parameters

stub BowireRecordingStep

Returns

BowireRecordingStep

GetScenarioStates()

Current state of every scenario declared in the recording (name → state).

public IReadOnlyDictionary<string, string> GetScenarioStates()

Returns

IReadOnlyDictionary<string, string>

GetStub(string)

Find a stub by id, or null.

public BowireRecordingStep? GetStub(string id)

Parameters

id string

Returns

BowireRecordingStep

HandleAsync(HttpContext, Func<Task>)

public Task HandleAsync(HttpContext ctx, Func<Task> next)

Parameters

ctx HttpContext
next Func<Task>

Returns

Task

ListStubs()

Snapshot of the current stubs (recording steps).

public IReadOnlyList<BowireRecordingStep> ListStubs()

Returns

IReadOnlyList<BowireRecordingStep>

RemoveStub(string)

Remove the stub with the given id. False when absent.

public bool RemoveStub(string id)

Parameters

id string

Returns

bool

ReplaceRecording(BowireRecording)

Swap the in-memory recording. Called by RecordingWatcher when the source file changes. Resets the stateful cursor because the new file defines a fresh step sequence — carrying the old index over would almost certainly land on a different step than the user meant.

public void ReplaceRecording(BowireRecording next)

Parameters

next BowireRecording

ResetScenarios()

Reset every scenario back to its initial state (Started).

public void ResetScenarios()

ResetStubs()

Restore the stubs to the baseline recording (as loaded / last hot-reloaded).

public void ResetStubs()

SetScenarioState(string, string)

Force a scenario to a state. False when no stub declares that scenario name.

public bool SetScenarioState(string name, string state)

Parameters

name string
state string

Returns

bool

UpdateStub(string, BowireRecordingStep)

Replace the stub with the given id (id preserved). False when absent.

public bool UpdateStub(string id, BowireRecordingStep stub)

Parameters

id string
stub BowireRecordingStep

Returns

bool