From 38d1cba644fdde1955b610a05ace5791b4a546c2 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Thu, 18 Jan 2018 20:38:33 +0100 Subject: [PATCH] [Tests] Make the HttpClientTest.TestEscapedURI test ignore timeout The server used in the test sometimes cannot be reached, there's no need to treat it as a failure. Ignore the timeout with Assert.Ignore instead. --- .../System.Net.Http/HttpClientTest.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/BCL-Tests/LocalTests.NUnit/System.Net.Http/HttpClientTest.cs b/tests/BCL-Tests/LocalTests.NUnit/System.Net.Http/HttpClientTest.cs index b82b12286d1..c86f317ec61 100644 --- a/tests/BCL-Tests/LocalTests.NUnit/System.Net.Http/HttpClientTest.cs +++ b/tests/BCL-Tests/LocalTests.NUnit/System.Net.Http/HttpClientTest.cs @@ -1,6 +1,7 @@ using System; using System.Net; using System.Net.Http; +using System.Threading.Tasks; using NUnit.Framework; @@ -19,12 +20,15 @@ public void TestUnescapedURI () var t = client.GetStringAsync("http://naver.com/t[e]st.txt"); t.Wait(1000); Assert.IsNotNull(t.Result); - } - catch (AggregateException e) - { + } catch (TaskCanceledException) { + Assert.Ignore ("Connection timed out"); + } catch (AggregateException e) { Assert.AreEqual (1, e.InnerExceptions.Count); - Assert.AreEqual (typeof(HttpRequestException), e.InnerExceptions[0].GetType ()); + if (e.InnerExceptions[0].GetType () == typeof (TaskCanceledException)) + Assert.Ignore ("Connection timed out"); + else + Assert.AreEqual (typeof(HttpRequestException), e.InnerExceptions[0].GetType ()); } } } -} \ No newline at end of file +}