Skip to content

Commit a85a39a

Browse files
committed
fix TestMethodForPlatformAttribute
replace Execute with ExecuteAsync and fix MSTEST0057 https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0057 (link currently dead)
1 parent 6e4a700 commit a85a39a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/Renci.SshNet.Tests/Common/TestMethodForPlatformAttribute.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
2+
using System.Runtime.CompilerServices;
23
using System.Runtime.InteropServices;
4+
using System.Threading.Tasks;
35

46
using Microsoft.VisualStudio.TestTools.UnitTesting;
57

@@ -8,18 +10,18 @@ namespace Renci.SshNet.Tests.Common
810
[AttributeUsage(AttributeTargets.Method)]
911
public sealed class TestMethodForPlatformAttribute : TestMethodAttribute
1012
{
11-
public TestMethodForPlatformAttribute(string platform)
13+
public TestMethodForPlatformAttribute(string platform, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1) : base(callerFilePath, callerLineNumber)
1214
{
1315
Platform = platform;
1416
}
1517

1618
public string Platform { get; }
1719

18-
public override TestResult[] Execute(ITestMethod testMethod)
20+
public override async Task<TestResult[]> ExecuteAsync(ITestMethod testMethod)
1921
{
2022
if (RuntimeInformation.IsOSPlatform(OSPlatform.Create(Platform)))
2123
{
22-
return base.Execute(testMethod);
24+
return await base.ExecuteAsync(testMethod);
2325
}
2426

2527
var message = $"Test not executed. The test is intended for the '{Platform}' platform only.";

0 commit comments

Comments
 (0)