protected ProxyBase(IRestClient restClient, ProxySettingCollection settingCollection, string appName) { proxySettings = settingCollection.GetByName(appName); this.restClient = restClient; this.restClient.BaseUrl = new Uri(proxySettings.Url); }
private void CreateSantaProxy() { mockRestClient .Setup(c => c.Execute(It.IsAny <IRestRequest>())) .Returns(new RestResponse() { Content = errorMessage == null ? JsonSerializer.Serialize(verdictDto) : errorMessage, StatusCode = statusCode, ErrorException = exception }); var settingCollection = new ProxySettingCollection() { Proxies = new ProxySettings[] { new ProxySettings() { Name = appName, Url = Url } } }; santaAppProxy = CreateProxy(mockRestClient.Object, settingCollection); }
public static ProxySettings GetByName(this ProxySettingCollection collection, string appName) { if (collection == null || collection.Proxies.Length == 0) { throw new ArgumentException($"Настройки для приложений не найдены"); } var proxySettings = collection.Proxies .FirstOrDefault(p => string.Equals( p.Name, appName, StringComparison.CurrentCultureIgnoreCase)); if (proxySettings == null) { throw new ArgumentException($"Настройки для приложения {appName} не обнаруженны"); } return(proxySettings); }
public SantaAppProxy(IRestClient restClient, ProxySettingCollection settingCollection) : base(restClient, settingCollection, AppName) { }
protected override IBehaviorProxy CreateProxy(IRestClient restClient, ProxySettingCollection settingCollection) => new SantaAppProxy(restClient, settingCollection);
protected abstract IBehaviorProxy CreateProxy(IRestClient restClient, ProxySettingCollection settingCollection);