// Copyright (c) Microsoft Corporation. All rights reserved. // EnvironmentSpecificFactAttribute.cs using Xunit; namespace AutoGen.Tests; /// /// A base class for environment-specific fact attributes. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public abstract class EnvironmentSpecificFactAttribute : FactAttribute { private readonly string _skipMessage; /// /// Creates a new instance of the class. /// /// The message to be used when skipping the test marked with this attribute. protected EnvironmentSpecificFactAttribute(string skipMessage) { _skipMessage = skipMessage ?? throw new ArgumentNullException(nameof(skipMessage)); } public sealed override string Skip => IsEnvironmentSupported() ? string.Empty : _skipMessage; /// /// A method used to evaluate whether to skip a test marked with this attribute. Skips iff this method evaluates to false. /// protected abstract bool IsEnvironmentSupported(); }