public void When_sending_a_request() { var endpoint = new Uri("http://localhost/api"); ServicePointManager.FindServicePoint(endpoint).ConnectionLeaseTimeout.ShouldBe(-1); using (IRestClient client = new RestClient()) { client.SendAsync(new HttpRequestMessage(HttpMethod.Get, endpoint)); ServicePointManager.FindServicePoint(endpoint) .ConnectionLeaseTimeout .ShouldBe((int)1.Minutes().TotalMilliseconds); client.Endpoints.Length.ShouldBe(1); client.Endpoints[0].ShouldBe(endpoint); client.ClearEndpoints(); client.Endpoints.ShouldBeEmpty(); } }
public void When_sending_a_request_with_string_uri() { const string Endpoint = "http://localhost:33/api"; var endpointUri = new Uri(Endpoint); ServicePointManager.FindServicePoint(endpointUri).ConnectionLeaseTimeout.ShouldBe(-1); using (IRestClient client = new RestClient()) { client.SendAsync(new HttpRequestMessage(HttpMethod.Get, Endpoint)); ServicePointManager.FindServicePoint(endpointUri) .ConnectionLeaseTimeout .ShouldBe((int)1.Minutes().TotalMilliseconds); client.Endpoints.Length.ShouldBe(1); client.Endpoints[0].OriginalString.ShouldBe(Endpoint); client.ClearEndpoints(); client.Endpoints.ShouldBeEmpty(); } }