From ea2f416ea4247c4dc396dfb0cbec2df4ccf46978 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 16:28:44 +0000 Subject: [PATCH 1/2] Initial plan From ec7c88a0de19dfc69bdf980435337038a875b5e3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 16:35:16 +0000 Subject: [PATCH 2/2] Replace TestMethodForPlatformAttribute with OSCondition attribute Co-authored-by: Rob-Hague <5132141+Rob-Hague@users.noreply.github.com> --- ...rTest_Connect_TimeoutConnectingToServer.cs | 11 +++--- ...orTest_Connect_TimeoutConnectingToProxy.cs | 11 +++--- ...orTest_Connect_TimeoutConnectingToProxy.cs | 11 +++--- ...orTest_Connect_TimeoutConnectingToProxy.cs | 11 +++--- ...est_Dispose_PortStarted_ChannelNotBound.cs | 5 +-- ...icTest_Stop_PortStarted_ChannelNotBound.cs | 5 +-- .../Common/TestMethodForPlatformAttribute.cs | 39 ------------------- 7 files changed, 28 insertions(+), 65 deletions(-) delete mode 100644 test/Renci.SshNet.Tests/Common/TestMethodForPlatformAttribute.cs diff --git a/test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_TimeoutConnectingToServer.cs b/test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_TimeoutConnectingToServer.cs index 46a45a355..6da172eb2 100644 --- a/test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_TimeoutConnectingToServer.cs +++ b/test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_TimeoutConnectingToServer.cs @@ -3,14 +3,12 @@ using System.Globalization; using System.Net; using System.Net.Sockets; -using System.Runtime.InteropServices; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using Renci.SshNet.Common; -using Renci.SshNet.Tests.Common; namespace Renci.SshNet.Tests.Classes.Connection { @@ -72,7 +70,8 @@ protected override void Act() } } - [TestMethodForPlatform(nameof(OSPlatform.Windows))] + [TestMethod] + [OSCondition(OperatingSystems.Windows)] public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnWindows() { Assert.IsNull(_actualException.InnerException); @@ -80,7 +79,8 @@ public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnWindows() Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "Connection failed to establish within {0} milliseconds.", _connectionInfo.Timeout.TotalMilliseconds), _actualException.Message); } - [TestMethodForPlatform(nameof(OSPlatform.Linux))] + [TestMethod] + [OSCondition(OperatingSystems.Linux)] public void ConnectShouldHaveThrownSocketExceptionOnLinux() { Assert.IsNull(_actualException.InnerException); @@ -88,7 +88,8 @@ public void ConnectShouldHaveThrownSocketExceptionOnLinux() Assert.AreEqual("Connection refused", _actualException.Message); } - [TestMethodForPlatform(nameof(OSPlatform.Windows))] + [TestMethod] + [OSCondition(OperatingSystems.Windows)] public void ConnectShouldHaveRespectedTimeoutOnWindows() { var errorText = string.Format("Elapsed: {0}, Timeout: {1}", diff --git a/test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutConnectingToProxy.cs b/test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutConnectingToProxy.cs index eb466816d..9a07250c8 100644 --- a/test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutConnectingToProxy.cs +++ b/test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_TimeoutConnectingToProxy.cs @@ -3,14 +3,12 @@ using System.Globalization; using System.Net; using System.Net.Sockets; -using System.Runtime.InteropServices; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using Renci.SshNet.Common; -using Renci.SshNet.Tests.Common; namespace Renci.SshNet.Tests.Classes.Connection { @@ -82,7 +80,8 @@ protected override void Act() } } - [TestMethodForPlatform(nameof(OSPlatform.Windows))] + [TestMethod] + [OSCondition(OperatingSystems.Windows)] public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnWindows() { Assert.IsNull(_actualException.InnerException); @@ -90,7 +89,8 @@ public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnWindows() Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "Connection failed to establish within {0} milliseconds.", _connectionInfo.Timeout.TotalMilliseconds), _actualException.Message); } - [TestMethodForPlatform(nameof(OSPlatform.Linux))] + [TestMethod] + [OSCondition(OperatingSystems.Linux)] public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnLinux() { Assert.IsNull(_actualException.InnerException); @@ -98,7 +98,8 @@ public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnLinux() Assert.AreEqual("Connection refused", _actualException.Message); } - [TestMethodForPlatform(nameof(OSPlatform.Windows))] + [TestMethod] + [OSCondition(OperatingSystems.Windows)] public void ConnectShouldHaveRespectedTimeoutOnWindows() { var errorText = string.Format("Elapsed: {0}, Timeout: {1}", diff --git a/test/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_TimeoutConnectingToProxy.cs b/test/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_TimeoutConnectingToProxy.cs index b0ae1d88f..1e5a1edff 100644 --- a/test/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_TimeoutConnectingToProxy.cs +++ b/test/Renci.SshNet.Tests/Classes/Connection/Socks4ConnectorTest_Connect_TimeoutConnectingToProxy.cs @@ -2,14 +2,12 @@ using System.Diagnostics; using System.Globalization; using System.Net.Sockets; -using System.Runtime.InteropServices; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using Renci.SshNet.Common; -using Renci.SshNet.Tests.Common; namespace Renci.SshNet.Tests.Classes.Connection { @@ -70,7 +68,8 @@ protected override void Act() } } - [TestMethodForPlatform(nameof(OSPlatform.Windows))] + [TestMethod] + [OSCondition(OperatingSystems.Windows)] public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnWindows() { Assert.IsNull(_actualException.InnerException); @@ -78,7 +77,8 @@ public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnWindows() Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "Connection failed to establish within {0} milliseconds.", _connectionInfo.Timeout.TotalMilliseconds), _actualException.Message); } - [TestMethodForPlatform(nameof(OSPlatform.Linux))] + [TestMethod] + [OSCondition(OperatingSystems.Linux)] public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnLinux() { Assert.IsNull(_actualException.InnerException); @@ -86,7 +86,8 @@ public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnLinux() Assert.AreEqual("Connection refused", _actualException.Message); } - [TestMethodForPlatform(nameof(OSPlatform.Windows))] + [TestMethod] + [OSCondition(OperatingSystems.Windows)] public void ConnectShouldHaveRespectedTimeoutOnWindows() { var errorText = string.Format("Elapsed: {0}, Timeout: {1}", diff --git a/test/Renci.SshNet.Tests/Classes/Connection/Socks5ConnectorTest_Connect_TimeoutConnectingToProxy.cs b/test/Renci.SshNet.Tests/Classes/Connection/Socks5ConnectorTest_Connect_TimeoutConnectingToProxy.cs index 59e5e0bce..4050ea1c1 100644 --- a/test/Renci.SshNet.Tests/Classes/Connection/Socks5ConnectorTest_Connect_TimeoutConnectingToProxy.cs +++ b/test/Renci.SshNet.Tests/Classes/Connection/Socks5ConnectorTest_Connect_TimeoutConnectingToProxy.cs @@ -2,14 +2,12 @@ using System.Diagnostics; using System.Globalization; using System.Net.Sockets; -using System.Runtime.InteropServices; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using Renci.SshNet.Common; -using Renci.SshNet.Tests.Common; namespace Renci.SshNet.Tests.Classes.Connection { @@ -71,7 +69,8 @@ protected override void Act() } } - [TestMethodForPlatform(nameof(OSPlatform.Windows))] + [TestMethod] + [OSCondition(OperatingSystems.Windows)] public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnWindows() { Assert.IsNull(_actualException.InnerException); @@ -79,7 +78,8 @@ public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnWindows() Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "Connection failed to establish within {0} milliseconds.", _connectionInfo.Timeout.TotalMilliseconds), _actualException.Message); } - [TestMethodForPlatform(nameof(OSPlatform.Linux))] + [TestMethod] + [OSCondition(OperatingSystems.Linux)] public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnLinux() { Assert.IsNull(_actualException.InnerException); @@ -87,7 +87,8 @@ public void ConnectShouldHaveThrownSshOperationTimeoutExceptionOnLinux() Assert.AreEqual("Connection refused", _actualException.Message); } - [TestMethodForPlatform(nameof(OSPlatform.Windows))] + [TestMethod] + [OSCondition(OperatingSystems.Windows)] public void ConnectShouldHaveRespectedTimeoutOnWindows() { var errorText = string.Format("Elapsed: {0}, Timeout: {1}", diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelNotBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelNotBound.cs index f8bee3579..3d6e5c602 100644 --- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelNotBound.cs +++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Dispose_PortStarted_ChannelNotBound.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Net; using System.Net.Sockets; -using System.Runtime.InteropServices; using System.Threading; using Microsoft.Extensions.Logging.Abstractions; @@ -12,7 +11,6 @@ using Renci.SshNet.Channels; using Renci.SshNet.Common; -using Renci.SshNet.Tests.Common; namespace Renci.SshNet.Tests.Classes { @@ -108,7 +106,8 @@ public void ForwardedPortShouldRefuseNewConnections() } // TODO We should investigate why this method doesn't work on Linux - [TestMethodForPlatform(nameof(OSPlatform.Windows))] + [TestMethod] + [OSCondition(OperatingSystems.Windows)] public void ExistingConnectionShouldBeClosed() { try diff --git a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound.cs b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound.cs index 62245403f..034a77494 100644 --- a/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound.cs +++ b/test/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Net; using System.Net.Sockets; -using System.Runtime.InteropServices; using System.Threading; using Microsoft.Extensions.Logging.Abstractions; @@ -12,7 +11,6 @@ using Renci.SshNet.Channels; using Renci.SshNet.Common; -using Renci.SshNet.Tests.Common; namespace Renci.SshNet.Tests.Classes { @@ -112,7 +110,8 @@ public void ForwardedPortShouldRefuseNewConnections() } // TODO We should investigate why this method doesn't work on Linux - [TestMethodForPlatform(nameof(OSPlatform.Windows))] + [TestMethod] + [OSCondition(OperatingSystems.Windows)] public void ExistingConnectionShouldBeClosed() { try diff --git a/test/Renci.SshNet.Tests/Common/TestMethodForPlatformAttribute.cs b/test/Renci.SshNet.Tests/Common/TestMethodForPlatformAttribute.cs deleted file mode 100644 index dbccbb22a..000000000 --- a/test/Renci.SshNet.Tests/Common/TestMethodForPlatformAttribute.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Threading.Tasks; - -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Renci.SshNet.Tests.Common -{ - [AttributeUsage(AttributeTargets.Method)] - public sealed class TestMethodForPlatformAttribute : TestMethodAttribute - { - public TestMethodForPlatformAttribute(string platform, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1) : base(callerFilePath, callerLineNumber) - { - Platform = platform; - } - - public string Platform { get; } - - public override async Task ExecuteAsync(ITestMethod testMethod) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Create(Platform))) - { - return await base.ExecuteAsync(testMethod); - } - - var message = $"Test not executed. The test is intended for the '{Platform}' platform only."; - return new[] - { - new TestResult - { - Outcome = UnitTestOutcome.Inconclusive, - TestFailureException = new AssertInconclusiveException(message) - } - }; - - } - } -}