Class MockServer

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

Standalone mock host used by the bowire mock CLI subcommand. Spins up a minimal Kestrel pipeline with UseBowireMock mounted at the root and no fallback service behind it, so unmatched requests return 404 instead of falling through.

public sealed class MockServer : IAsyncDisposable
Inheritance
MockServer
Implements
Inherited Members

Remarks

Construct the server with StartAsync(MockServerOptions, CancellationToken); it runs until WaitForShutdownAsync(CancellationToken) returns or the instance is disposed. Cancelling the cancellation token passed into StartAsync(MockServerOptions, CancellationToken) is equivalent to DisposeAsync().

Properties

Faults

Live fault-injection rules (#170) — the same instance the request pipeline reads, so swapping Rules on it re-configures a RUNNING mock (management endpoint / UI editor). Reference assignment is atomic; in-flight requests keep the list they already picked up.

public FaultRuleSet Faults { get; }

Property Value

FaultRuleSet

Handler

The live mock request handler, captured after the pipeline is built (#404). Exposes per-stub CRUD for the management API. Null until the host has started building its pipeline.

public MockHandler? Handler { get; }

Property Value

MockHandler

Port

TCP port the server is actually listening on. Equal to Port when the caller specified one; when the caller passed 0, this returns the OS-assigned port picked at bind time. Useful for tests that don't want to race on a hard-coded port number.

public int Port { get; }

Property Value

int

TransportPorts

Bound ports for every plugin-contributed transport host that started successfully. Keyed by Id — typical entries are "mqtt" (when the MQTT plugin is loaded and the recording has MQTT steps), "amqp", etc.

public IReadOnlyDictionary<string, int> TransportPorts { get; }

Property Value

IReadOnlyDictionary<string, int>

Methods

DisposeAsync()

public ValueTask DisposeAsync()

Returns

ValueTask

StartAsync(MockServerOptions, CancellationToken)

Build, start and return a running mock server. Throws on startup failure (invalid recording, port already in use, ...).

public static Task<MockServer> StartAsync(MockServerOptions options, CancellationToken ct)

Parameters

options MockServerOptions
ct CancellationToken

Returns

Task<MockServer>

WaitForShutdownAsync(CancellationToken)

Block until the host shuts down (Ctrl+C, explicit stop).

public Task WaitForShutdownAsync(CancellationToken ct)

Parameters

ct CancellationToken

Returns

Task