Testing patterns
Thresh is designed to be test-friendly through abstractions and fakes.
Unit testing HTTP callers
Mock or stub ILcuHttpClient to validate path usage and failure handling.
public sealed class StubLcuHttpClient : ILcuHttpClient
{
public string? LastPath { get; private set; }
public Task<T?> GetAsync<T>(string path, CancellationToken ct = default)
{
LastPath = path;
return Task.FromResult(default(T));
}
public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken ct = default)
=> throw new NotSupportedException();
}
Event stream tests
- Use fake event stream implementations for deterministic event dispatch tests.
- Isolate reconnection and lifecycle tests from network state.
Integration tests
Use integration tests sparingly for transport realism (lockfile and local client behavior). Keep them explicit and non-flaky, and distinguish them from deterministic unit suites.