using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Jackett.Common.Models.Config; using Jackett.Common.Services.Interfaces; using Jackett.Common.Utils.Clients; using NLog; namespace Jackett.Test.TestHelpers { // Currently not used in any Unit tests. Leaving it for potential future testing purposes. public class TestWebClient : WebClient { private readonly Dictionary> _requestCallbacks = new Dictionary>(); public TestWebClient(IProcessService p, Logger l, IConfigurationService c, ServerConfig sc) : base(p, l, c, sc) { } public void RegisterRequestCallback(WebRequest req, Func f) => _requestCallbacks.Add(req, f); public override Task GetResultAsync(WebRequest request) => Task.FromResult(_requestCallbacks.First(r => r.Key.Equals(request)).Value.Invoke(request)); public override void Init() { } } }