public async Task WhenUsingCustomProxySettingsWithoutCredentials_ThenRequestsAreSentToProxy() { using (var proxy = new InProcessHttpProxy()) { var adapter = new HttpProxyAdapter(); adapter.ActivateCustomProxySettings( new Uri($"http://localhost:{proxy.Port}"), ProxyBypassList, null); await SendWebRequest(SampleHttpsUrl); Assert.AreEqual(1, proxy.ConnectionTargets.Distinct().Count()); CollectionAssert.Contains(proxy.ConnectionTargets, SampleHttpsUrl.Host); } }
public async Task WhenRevertedToSystemProxySettings_ThenRequestsAreNotSentToProxy() { var proxyCredentials = new NetworkCredential("proxyuser", "proxypass"); using (var proxy = new InProcessAuthenticatingHttpProxy( proxyCredentials)) { var adapter = new HttpProxyAdapter(); adapter.ActivateCustomProxySettings( new Uri($"http://localhost:{proxy.Port}"), ProxyBypassList, proxyCredentials); adapter.ActivateSystemProxySettings(); await SendWebRequest(SampleHttpsUrl); CollectionAssert.DoesNotContain(proxy.ConnectionTargets, SampleHttpsUrl.Host); } }