public void TestAbortReceive([Values(true, false)] bool async) { var request = new JsonWebRequest <HttpBinGetResponse>($"{default_protocol}://{host}/get") { Method = HttpMethod.Get, AllowInsecureRequests = true, }; bool hasThrown = false; request.Failed += exception => hasThrown = exception != null; request.Started += () => request.Abort(); if (async) { Assert.DoesNotThrowAsync(request.PerformAsync); } else { Assert.DoesNotThrow(request.Perform); } Assert.IsTrue(request.Completed); Assert.IsTrue(request.Aborted); Assert.IsTrue(request.ResponseObject == null); Assert.IsFalse(hasThrown); }
public void TestAbortReceive(bool async) { var request = new JsonWebRequest <HttpBinGetResponse>("https://httpbin.org/get") { Method = HttpMethod.GET }; bool hasThrown = false; request.Failed += exception => hasThrown = exception != null; request.Started += () => request.Abort(); if (async) { Assert.DoesNotThrowAsync(request.PerformAsync); } else { Assert.DoesNotThrow(request.Perform); } Assert.IsTrue(request.Completed); Assert.IsTrue(request.Aborted); Assert.IsTrue(request.ResponseObject == null); Assert.IsFalse(hasThrown); }