瀏覽代碼

Fix platform fact/theory attributes.

Throwing on `Skip` setter was causing all subsequent tests in class to be ignored.
Steven Kirk 2 年之前
父節點
當前提交
4c9bf8e53a

+ 11 - 2
tests/Avalonia.IntegrationTests.Appium/PlatformFactAttribute.cs

@@ -17,6 +17,7 @@ namespace Avalonia
     internal class PlatformFactAttribute : FactAttribute
     internal class PlatformFactAttribute : FactAttribute
     {
     {
         private readonly string? _reason;
         private readonly string? _reason;
+        private string? _skip;
 
 
         public PlatformFactAttribute(TestPlatforms platforms, string? reason = null)
         public PlatformFactAttribute(TestPlatforms platforms, string? reason = null)
         {
         {
@@ -28,8 +29,16 @@ namespace Avalonia
 
 
         public override string? Skip
         public override string? Skip
         {
         {
-            get => IsSupported() ? null : $"Ignored on {RuntimeInformation.OSDescription}" + (_reason is not null ? $" reason: \"{_reason}\"" : "");
-            set => throw new NotSupportedException();
+            get
+            {
+                if (_skip is not null)
+                    return _skip;
+                if (!IsSupported())
+                    return $"Ignored on {RuntimeInformation.OSDescription}" +
+                           (_reason is not null ? $" reason: '{_reason}'" : "");
+                return null;
+            }
+            set => _skip = value;
         }
         }
 
 
         private bool IsSupported()
         private bool IsSupported()

+ 9 - 2
tests/Avalonia.IntegrationTests.Appium/PlatformTheoryAttribute.cs

@@ -7,14 +7,21 @@ namespace Avalonia.IntegrationTests.Appium
 {
 {
     internal class PlatformTheoryAttribute : TheoryAttribute
     internal class PlatformTheoryAttribute : TheoryAttribute
     {
     {
+        private string? _skip;
+
         public PlatformTheoryAttribute(TestPlatforms platforms = TestPlatforms.All) => Platforms = platforms;
         public PlatformTheoryAttribute(TestPlatforms platforms = TestPlatforms.All) => Platforms = platforms;
 
 
         public TestPlatforms Platforms { get; }
         public TestPlatforms Platforms { get; }
 
 
         public override string? Skip
         public override string? Skip
         {
         {
-            get => IsSupported() ? null : $"Ignored on {RuntimeInformation.OSDescription}";
-            set => throw new NotSupportedException();
+            get
+            {
+                if (_skip is not null)
+                    return _skip;
+                return !IsSupported() ? $"Ignored on {RuntimeInformation.OSDescription}" : null;
+            }
+            set => _skip = value;
         }
         }
 
 
         private bool IsSupported()
         private bool IsSupported()