From e941498839cbb75e5c8dc4006bf1f3eefa7b1a1b Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sun, 25 Mar 2018 18:57:55 +1300 Subject: [PATCH] Revert "Add conditional test attribute for WebSockets (#1709) (#1710)" (#1711) This reverts commit 5f64ecfd4d9b45e9500be7a0f92b086439ed7127. --- .../HubConnectionTests.cs | 2 +- .../WebSocketsSupportedConditionAttribute.cs | 39 ------------------- .../DefaultTransportFactoryTests.cs | 4 +- .../EndToEndTests.cs | 8 ++-- .../WebSocketsTransportTests.cs | 14 +++---- .../MapConnectionHandlerTests.cs | 3 +- 6 files changed, 15 insertions(+), 55 deletions(-) delete mode 100644 test/Microsoft.AspNetCore.SignalR.Tests.Utils/WebSocketsSupportedConditionAttribute.cs diff --git a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs index 64b25af727..c9ef03fa5c 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs @@ -724,7 +724,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests } [ConditionalFact] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public async Task WebSocketOptionsAreApplied() { using (StartLog(out var loggerFactory, $"{nameof(WebSocketOptionsAreApplied)}")) diff --git a/test/Microsoft.AspNetCore.SignalR.Tests.Utils/WebSocketsSupportedConditionAttribute.cs b/test/Microsoft.AspNetCore.SignalR.Tests.Utils/WebSocketsSupportedConditionAttribute.cs deleted file mode 100644 index f7d4d9b896..0000000000 --- a/test/Microsoft.AspNetCore.SignalR.Tests.Utils/WebSocketsSupportedConditionAttribute.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; -using Microsoft.AspNetCore.Testing.xunit; - -namespace Microsoft.AspNetCore.SignalR.Tests -{ - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] - public class WebSocketsSupportedConditionAttribute : Attribute, ITestCondition - { - public bool IsMet - { - get - { -#if NETCOREAPP2_1 - // .NET Core 2.1 and greater has sockets - return true; -#else - // Non-Windows platforms have sockets - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return true; - } - - // Windows 8 and greater has sockets - if (Environment.Version >= new Version(6, 2)) - { - return true; - } - - return false; -#endif - } - } - - public string SkipReason => "No WebSockets Client for this platform"; - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/DefaultTransportFactoryTests.cs b/test/Microsoft.AspNetCore.SignalR.Tests/DefaultTransportFactoryTests.cs index 02c0f7ae27..e8a93fd4f6 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests/DefaultTransportFactoryTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests/DefaultTransportFactoryTests.cs @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests [InlineData(TransportType.WebSockets, typeof(WebSocketsTransport))] [InlineData(TransportType.ServerSentEvents, typeof(ServerSentEventsTransport))] [InlineData(TransportType.LongPolling, typeof(LongPollingTransport))] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public void DefaultTransportFactoryCreatesRequestedTransportIfAvailable(TransportType requestedTransport, Type expectedTransportType) { var transportFactory = new DefaultTransportFactory(requestedTransport, loggerFactory: null, httpClient: new HttpClient(), httpOptions: null); @@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalFact] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public void DefaultTransportFactoryCreatesWebSocketsTransportIfAvailable() { Assert.IsType( diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs b/test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs index 92e64fdfe8..e51ba6489e 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs @@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalFact] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public async Task WebSocketsTest() { using (StartLog(out var loggerFactory)) @@ -118,7 +118,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalFact] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public async Task HTTPRequestsNotSentWhenWebSocketsTransportRequested() { using (StartLog(out var loggerFactory)) @@ -251,7 +251,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalTheory] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] [MemberData(nameof(MessageSizesData))] public async Task ConnectionCanSendAndReceiveDifferentMessageSizesWebSocketsTransport(string message) { @@ -303,7 +303,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalFact] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public async Task ServerClosesConnectionWithErrorIfHubCannotBeCreated_WebSocket() { try diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/WebSocketsTransportTests.cs b/test/Microsoft.AspNetCore.SignalR.Tests/WebSocketsTransportTests.cs index d718ac7c9c..fd229fed24 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests/WebSocketsTransportTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests/WebSocketsTransportTests.cs @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalFact] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public void HttpOptionsSetOntoWebSocketOptions() { ClientWebSocketOptions webSocketsOptions = null; @@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalFact] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public async Task WebSocketsTransportStopsSendAndReceiveLoopsWhenTransportIsStopped() { using (StartLog(out var loggerFactory)) @@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalFact(Skip = "Issue in ClientWebSocket prevents user-agent being set - https://github.com/dotnet/corefx/issues/26627")] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public async Task WebSocketsTransportSendsUserAgent() { using (StartLog(out var loggerFactory)) @@ -113,7 +113,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalFact] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public async Task WebSocketsTransportStopsWhenConnectionChannelClosed() { using (StartLog(out var loggerFactory)) @@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalTheory] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] [InlineData(TransferFormat.Text)] [InlineData(TransferFormat.Binary)] public async Task WebSocketsTransportStopsWhenConnectionClosedByTheServer(TransferFormat transferFormat) @@ -151,7 +151,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests } [ConditionalTheory] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] [InlineData(TransferFormat.Text)] [InlineData(TransferFormat.Binary)] public async Task WebSocketsTransportSetsTransferFormat(TransferFormat transferFormat) @@ -172,7 +172,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests [ConditionalTheory] [InlineData(TransferFormat.Text | TransferFormat.Binary)] // Multiple values not allowed [InlineData((TransferFormat)42)] // Unexpected value - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public async Task WebSocketsTransportThrowsForInvalidTransferFormat(TransferFormat transferFormat) { using (StartLog(out var loggerFactory)) diff --git a/test/Microsoft.AspNetCore.Sockets.Tests/MapConnectionHandlerTests.cs b/test/Microsoft.AspNetCore.Sockets.Tests/MapConnectionHandlerTests.cs index 0e27f32aed..7147d126f8 100644 --- a/test/Microsoft.AspNetCore.Sockets.Tests/MapConnectionHandlerTests.cs +++ b/test/Microsoft.AspNetCore.Sockets.Tests/MapConnectionHandlerTests.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Connections; -using Microsoft.AspNetCore.SignalR.Tests; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -69,7 +68,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests } [ConditionalFact] - [WebSocketsSupportedCondition] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")] public async Task MapConnectionHandlerWithWebSocketSubProtocolSetsProtocol() { var host = BuildWebHost("/socket",