using System.Net; namespace dy.net.Tests.TestInfrastructure; internal sealed class StubHttpClientFactory : IHttpClientFactory, IDisposable { private readonly HttpClient _client; public StubHttpClientFactory(HttpMessageHandler handler, string baseAddress = null) { _client = new HttpClient(handler, true); if (!string.IsNullOrWhiteSpace(baseAddress)) _client.BaseAddress = new Uri(baseAddress); } public HttpClient CreateClient(string name) => _client; public void Dispose() => _client.Dispose(); } internal sealed class LiveHttpClientFactory : IHttpClientFactory, IDisposable { private readonly HttpClient _secureClient = new(new HttpClientHandler()); private readonly HttpClient _insecureClient = new(new HttpClientHandler { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }); public HttpClient CreateClient(string name) => name == "webdav-insecure" ? _insecureClient : _secureClient; public void Dispose() { _secureClient.Dispose(); _insecureClient.Dispose(); } }