| 1234567891011121314151617181920212223242526272829303132333435 |
- using System.Runtime.InteropServices;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- namespace Renci.SshNet.Tests.Common
- {
- public sealed class TestMethodForPlatformAttribute : TestMethodAttribute
- {
- public TestMethodForPlatformAttribute(string platform)
- {
- Platform = platform;
- }
- public string Platform { get; }
- public override TestResult[] Execute(ITestMethod testMethod)
- {
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Create(Platform)))
- {
- return base.Execute(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)
- }
- };
- }
- }
- }
|