FindMyFiles

FindMyFiles.Engine

FakeEngineClient Class

Deterministic in-memory engine for UI tests and unelevated development (`--fake-engine`). 100k entries from a fixed seed; substring search only. Contract-conforming (EngineClientContractTests): query-syntax verdicts come from the shared golden fixture (contract/golden/invalid_queries.json, pinned by the real Rust parser — verdict drift is caught on the Rust side), cancellation is honored, and BumpEpoch() lets tests drive the Stale→requery recovery path without a real engine.

public sealed class FakeEngineClient : FindMyFiles.Engine.IEngineClient, System.IDisposable

Inheritance System.Object → FakeEngineClient

Implements IEngineClient, System.IDisposable

Constructors

FakeEngineClient(bool) Constructor

Builds the fake. The default (empty false) generates the deterministic 100k-row dataset that backs --fake-engine; CreateEmpty() passes empty true for the unelevated no-service stand-in.

public FakeEngineClient(bool empty=false);

Parameters

empty System.Boolean

When true, no rows are generated (the disconnected auto-fallback); when false, the seeded demo dataset is built.

Properties

FakeEngineClient.Connection Property

In-proc: no transport, no state transitions.

public FindMyFiles.Engine.EngineConnectionState Connection { get; }

Implements Connection

Property Value

EngineConnectionState

FakeEngineClient.IsEmpty Property

True for the unelevated auto-fallback instance (no rows) — the status badge says disconnected, not fake.

public bool IsEmpty { get; }

Property Value

System.Boolean

Methods

FakeEngineClient.BumpEpoch() Method

Test hook: structurally invalidate every result handed out so far — their next GetRangeAsync throws StaleResultException, exactly like a real index rebuild (UI Stale→requery recovery).

public void BumpEpoch();

FakeEngineClient.CreateEmpty() Method

Visibly empty stand-in for the unelevated no-service start — searching demo rows has no practical value (user verdict), so the auto-fallback shows zero results plus the setup notification instead. The data-bearing fake stays what --fake-engine is for.

public static FindMyFiles.Engine.FakeEngineClient CreateEmpty();

Returns

FakeEngineClient
A rowless fake that reports disconnected and yields no results.

FakeEngineClient.Dispose() Method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose();

Implements Dispose()

FakeEngineClient.GetStatsAsync(CancellationToken) Method

Observability snapshot for the performance panel.

public System.Threading.Tasks.Task<FindMyFiles.Engine.EngineStatsData?> GetStatsAsync(System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));

Parameters

ct System.Threading.CancellationToken

Cooperative cancellation token.

Implements GetStatsAsync(CancellationToken)

Returns

System.Threading.Tasks.Task<EngineStatsData>
The current engine stats, or null if unavailable.

FakeEngineClient.GetStatusAsync(CancellationToken) Method

Returns a snapshot of the current state (VolumeStatus) of every volume. Used for the initial display at startup and for the setup screen's decisions.

public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<FindMyFiles.Engine.VolumeStatus>> GetStatusAsync(System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));

Parameters

ct System.Threading.CancellationToken

Cooperative cancellation token.

Implements GetStatusAsync(CancellationToken)

Returns

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<VolumeStatus>>
A snapshot of the current status of every known volume.

Exceptions

EngineUnavailableException
service unreachable

FakeEngineClient.ListVolumesAsync(CancellationToken) Method

Returns the labels of the indexed volumes (those the engine currently recognizes).

public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<string>> ListVolumesAsync(System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));

Parameters

ct System.Threading.CancellationToken

Cooperative cancellation token.

Implements ListVolumesAsync(CancellationToken)

Returns

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<System.String>>
The labels of the volumes the engine currently knows about.

Exceptions

EngineUnavailableException
service unreachable

FakeEngineClient.SearchAsync(string, SearchOptions, CancellationToken) Method

Executes the query and returns a sort-settled result handle (Result) plus an optional timing trace. Pages are read lazily through the returned ISearchResult.

public System.Threading.Tasks.Task<FindMyFiles.Engine.SearchOutcome> SearchAsync(string query, FindMyFiles.Engine.SearchOptions options, System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));

Parameters

query System.String

The query text to execute.

options SearchOptions

Search options (sort order, flags).

ct System.Threading.CancellationToken

Cooperative cancellation token.

Implements SearchAsync(string, SearchOptions, CancellationToken)

Returns

System.Threading.Tasks.Task<SearchOutcome>
The sort-ordered result handle plus an optional timing trace.

Exceptions

QuerySyntaxException
malformed query text

EngineUnavailableException
service unreachable

FakeEngineClient.StartIndexingAsync(IReadOnlyList<string>, CancellationToken) Method

Requests that indexing/re-indexing start for the given volumes (fire-and-trigger: progress arrives via VolumeUpdated / IndexChanged). MFT reads require elevation, so the work runs on the service side.

public System.Threading.Tasks.Task StartIndexingAsync(System.Collections.Generic.IReadOnlyList<string> volumes, System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));

Parameters

volumes System.Collections.Generic.IReadOnlyList<System.String>

Labels of the volumes to (re)index.

ct System.Threading.CancellationToken

Cooperative cancellation token.

Implements StartIndexingAsync(IReadOnlyList<string>, CancellationToken)

Returns

System.Threading.Tasks.Task
A task that completes once the indexing request is accepted.

Exceptions

EngineUnavailableException
service unreachable

Events

FakeEngineClient.ConnectionChanged Event

Fires when the current Connection transitions. In-proc implementations never fire (always InProc). Fires from the pipe client's supervisor thread → marshal.

public event Action<EngineConnectionState>? ConnectionChanged;

Implements ConnectionChanged

Event Type

System.Action<EngineConnectionState>

FakeEngineClient.EngineErrorOccurred Event

The engine recorded a diagnostic (1=warn 2=error 3=panic). Details live in RecentErrors — pull on demand.

public event Action<int>? EngineErrorOccurred;

Implements EngineErrorOccurred

Event Type

System.Action<System.Int32>

FakeEngineClient.IndexChanged Event

New index content was published (USN apply or scan progress). The payload is the triggering volume label. The signal to re-evaluate the displayed query. Fires from an engine thread, so marshal to the UI thread (EngineEventMarshaler is the only crossing point).

public event Action<string>? IndexChanged;

Implements IndexChanged

Event Type

System.Action<System.String>

FakeEngineClient.VolumeUpdated Event

One volume's state transitioned (`Scanning`→`Ready` etc.). Emits the latest VolumeStatus. Fires from an engine thread → marshal.

public event Action<VolumeStatus>? VolumeUpdated;

Implements VolumeUpdated

Event Type

System.Action<VolumeStatus>