public void TestWebRequest(HttpStatusCode code, int result) { int total = 0; Assert.ThrowsAsync <WebException>(async() => await instance.WebPolicy.ExecuteAsync( () => { total++; throw new WebException("Test", new Exception(), WebExceptionStatus.Success, TestWebRequestCreate.CreateTestWebResponse("ss", code)); }) .ConfigureAwait(false)); Assert.AreEqual(result, total); }