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
recordingBowireRecordingoptionsMockOptionsloggerILoggerrecordingPathstring
Methods
AddStub(BowireRecordingStep)
Append a stub (assigning an id when it has none). Returns the stored stub.
public BowireRecordingStep AddStub(BowireRecordingStep stub)
Parameters
stubBowireRecordingStep
Returns
GetScenarioStates()
Current state of every scenario declared in the recording (name → state).
public IReadOnlyDictionary<string, string> GetScenarioStates()
Returns
GetStub(string)
Find a stub by id, or null.
public BowireRecordingStep? GetStub(string id)
Parameters
idstring
Returns
HandleAsync(HttpContext, Func<Task>)
public Task HandleAsync(HttpContext ctx, Func<Task> next)
Parameters
ctxHttpContextnextFunc<Task>
Returns
ListStubs()
Snapshot of the current stubs (recording steps).
public IReadOnlyList<BowireRecordingStep> ListStubs()
Returns
RemoveStub(string)
Remove the stub with the given id. False when absent.
public bool RemoveStub(string id)
Parameters
idstring
Returns
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
nextBowireRecording
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
Returns
UpdateStub(string, BowireRecordingStep)
Replace the stub with the given id (id preserved). False when absent.
public bool UpdateStub(string id, BowireRecordingStep stub)
Parameters
idstringstubBowireRecordingStep