-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Fix ClientWebSocket error message when endpoint is not a real websocket #29159
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,9 @@ public class ConnectTest : ClientWebSocketTestBase | |
{ | ||
public ConnectTest(ITestOutputHelper output) : base(output) { } | ||
|
||
[ActiveIssue(20360, TargetFrameworkMonikers.NetFramework)] | ||
[OuterLoop] // TODO: Issue #11345 | ||
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(UnavailableWebSocketServers))] | ||
public async Task ConnectAsync_NotWebSocketServer_ThrowsWebSocketExceptionWithMessage(Uri server) | ||
public async Task ConnectAsync_NotWebSocketServer_ThrowsWebSocketExceptionWithMessage(Uri server, string exceptionMessage) | ||
{ | ||
using (var cws = new ClientWebSocket()) | ||
{ | ||
|
@@ -29,7 +28,12 @@ public async Task ConnectAsync_NotWebSocketServer_ThrowsWebSocketExceptionWithMe | |
|
||
Assert.Equal(WebSocketError.Success, ex.WebSocketErrorCode); | ||
Assert.Equal(WebSocketState.Closed, cws.State); | ||
Assert.Equal(ResourceHelper.GetExceptionMessage("net_webstatus_ConnectFailure"), ex.Message); | ||
|
||
// The .Net Native toolchain optimizes away exception messages. | ||
if (!PlatformDetection.IsNetNative) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should still be able to use AssertExtension.Throws and save the exception it gives you back. And then check the error code. Using AssertExtension can remove you needing to check for "IsNetNative". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
My preference is to use the current if check in our test code, if the desire for checking @davidsh Do you have any thoughts on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thx for looking into this. Let's just keep it the way you're doing it in this PR. |
||
{ | ||
Assert.Equal(exceptionMessage, ex.Message); | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
".Net" -> ".NET"