diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2020-11-25 21:53:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-25 21:53:00 +0300 |
commit | 63b255f487d6924b570802e0ba18e8f87e9f4661 (patch) | |
tree | e9d696112211215cc273c26a464d95d9fc60cfd3 | |
parent | 4cfc831bf802bee7daca3b01e0ce5ed1b09b4574 (diff) |
improve ConnectAsync_CancellationRequestedAfterConnect_ThrowsOperation test (#45201)
Co-authored-by: wfurt <tweinfurt@yahoo.com>
-rw-r--r-- | src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs index 6d4d63a730f..265db6d6c41 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.IO; using System.Net.Test.Common; using System.Threading; using System.Threading.Tasks; @@ -277,10 +278,18 @@ namespace System.Net.WebSockets.Client.Tests releaseServer.SetResult(); clientSocket.Dispose(); } - }, server => server.AcceptConnectionAsync(async connection => + }, async server => { - await releaseServer.Task; - }), new LoopbackServer.Options { WebSocketEndpoint = true }); + try + { + await server.AcceptConnectionAsync(async connection => + { + await releaseServer.Task; + }); + } + // Ignore IO exception on server as there are race conditions when client is cancelling. + catch (IOException) { } + }, new LoopbackServer.Options { WebSocketEndpoint = true }); } } } |