diff options
| author | Murilo Ijanc <[email protected]> | 2026-07-26 12:42:38 -0300 |
|---|---|---|
| committer | Murilo Ijanc <[email protected]> | 2026-07-26 13:10:34 -0300 |
| commit | a2b10fd494fb389e556e40134031eb86e56e11e7 (patch) | |
| tree | 08b6df8a06f2c7c15488b90d57a6d8286cd57a22 /tests/Cepis.Tests/HttpTestBase.cs | |
| download | csharp-a2b10fd494fb389e556e40134031eb86e56e11e7.tar.gz | |
Initial importv0.1.0
Diffstat (limited to 'tests/Cepis.Tests/HttpTestBase.cs')
| -rw-r--r-- | tests/Cepis.Tests/HttpTestBase.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/Cepis.Tests/HttpTestBase.cs b/tests/Cepis.Tests/HttpTestBase.cs new file mode 100644 index 0000000..115ceef --- /dev/null +++ b/tests/Cepis.Tests/HttpTestBase.cs @@ -0,0 +1,33 @@ +namespace Cepis.Tests; + +/// <summary>A fake API and a real client pointed at it, torn down per test.</summary> +public abstract class HttpTestBase : IDisposable +{ + /// <summary>The fake API.</summary> + protected FakeServer Server { get; } = new(); + + /// <summary> + /// 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. + /// </summary> + protected CepisClient Client { get; } + + /// <summary>Start the server and point a client at it.</summary> + protected HttpTestBase() => + Client = new CepisClient(new CepisClientOptions + { + BaseUrl = Server.Url, + Timeout = TimeSpan.FromSeconds(30), + BackoffBase = TimeSpan.FromMilliseconds(1), + BackoffMax = TimeSpan.FromMilliseconds(20), + }); + + /// <summary>Stop the server and release the client.</summary> + public void Dispose() + { + Client.Dispose(); + Server.Dispose(); + GC.SuppressFinalize(this); + } +} |