namespace Cepis.Tests;
/// A fake API and a real client pointed at it, torn down per test.
public abstract class HttpTestBase : IDisposable
{
/// The fake API.
protected FakeServer Server { get; } = new();
///
/// A client whose backoff is shortened so the suite stays fast, and whose
/// per-attempt timeout is deliberately generous: a loaded machine must not
/// be able to turn a passing test into a spurious network failure.
///
protected CepisClient Client { get; }
/// Start the server and point a client at it.
protected HttpTestBase() =>
Client = new CepisClient(new CepisClientOptions
{
BaseUrl = Server.Url,
Timeout = TimeSpan.FromSeconds(30),
BackoffBase = TimeSpan.FromMilliseconds(1),
BackoffMax = TimeSpan.FromMilliseconds(20),
});
/// Stop the server and release the client.
public void Dispose()
{
Client.Dispose();
Server.Dispose();
GC.SuppressFinalize(this);
}
}