Browse Source

Fix platform fact/theory attributes.

Throwing on `Skip` setter was causing all subsequent tests in class to be ignored.
pull/10677/head
Steven Kirk 3 years ago
parent
commit
4c9bf8e53a
  1. 13
      tests/Avalonia.IntegrationTests.Appium/PlatformFactAttribute.cs
  2. 11
      tests/Avalonia.IntegrationTests.Appium/PlatformTheoryAttribute.cs

13
tests/Avalonia.IntegrationTests.Appium/PlatformFactAttribute.cs

@ -17,6 +17,7 @@ namespace Avalonia
internal class PlatformFactAttribute : FactAttribute
{
private readonly string? _reason;
private string? _skip;
public PlatformFactAttribute(TestPlatforms platforms, string? reason = null)
{
@ -28,8 +29,16 @@ namespace Avalonia
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()

11
tests/Avalonia.IntegrationTests.Appium/PlatformTheoryAttribute.cs

@ -7,14 +7,21 @@ namespace Avalonia.IntegrationTests.Appium
{
internal class PlatformTheoryAttribute : TheoryAttribute
{
private string? _skip;
public PlatformTheoryAttribute(TestPlatforms platforms = TestPlatforms.All) => Platforms = platforms;
public TestPlatforms Platforms { get; }
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()

Loading…
Cancel
Save