[Ignore] // This test requires TestService to run in a non-WinRT app. The code can be found in tests\Test.ADAL.NET.Unit\UnitTests.cs public async Task TimeoutTest() { const string TestServiceUrl = "http://localhost:8080"; HttpWebRequestWrapper webRequest = new HttpWebRequestWrapper(TestServiceUrl + "?delay=0&response_code=200") { TimeoutInMilliSeconds = 10000 }; await webRequest.GetResponseSyncOrAsync(new CallState(Guid.NewGuid(), false)); // Asynchronous try { webRequest = new HttpWebRequestWrapper(TestServiceUrl + "?delay=0&response_code=400") { TimeoutInMilliSeconds = 10000 }; await webRequest.GetResponseSyncOrAsync(new CallState(Guid.NewGuid(), false)); } catch (WebException ex) { Verify.AreEqual((int)(ex.Status), 7); // ProtocolError } try { webRequest = new HttpWebRequestWrapper(TestServiceUrl + "?delay=10000&response_code=200") { TimeoutInMilliSeconds = 500 }; await webRequest.GetResponseSyncOrAsync(new CallState(Guid.NewGuid(), false)); // Asynchronous } catch (WebException ex) { Verify.AreEqual((int)(ex.Status), 6); // RequestCanceled } }
public async Task TimeoutTest() { const string TestServiceUrl = "http://localhost:8080"; using (WebApp.Start <TestService>(TestServiceUrl)) { HttpWebRequestWrapper webRequest = new HttpWebRequestWrapper(TestServiceUrl + "?delay=0&response_code=200") { TimeoutInMilliSeconds = 10000 }; await webRequest.GetResponseSyncOrAsync(new CallState(Guid.NewGuid(), true)); // Synchronous webRequest = new HttpWebRequestWrapper(TestServiceUrl + "?delay=0&response_code=200") { TimeoutInMilliSeconds = 10000 }; await webRequest.GetResponseSyncOrAsync(new CallState(Guid.NewGuid(), false)); // Asynchronous try { webRequest = new HttpWebRequestWrapper(TestServiceUrl + "?delay=0&response_code=400") { TimeoutInMilliSeconds = 10000 }; await webRequest.GetResponseSyncOrAsync(new CallState(Guid.NewGuid(), false)); } catch (WebException ex) { Verify.AreEqual(ex.Status, WebExceptionStatus.ProtocolError); } try { webRequest = new HttpWebRequestWrapper(TestServiceUrl + "?delay=10000&response_code=200") { TimeoutInMilliSeconds = 500 }; await webRequest.GetResponseSyncOrAsync(new CallState(Guid.NewGuid(), true)); // Synchronous } catch (WebException ex) { Verify.AreEqual(ex.Status, WebExceptionStatus.Timeout); } try { webRequest = new HttpWebRequestWrapper(TestServiceUrl + "?delay=10000&response_code=200") { TimeoutInMilliSeconds = 500 }; await webRequest.GetResponseSyncOrAsync(new CallState(Guid.NewGuid(), false)); // Asynchronous } catch (WebException ex) { Verify.AreEqual(ex.Status, WebExceptionStatus.RequestCanceled); } } }