You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

EnvironmentSpecificFactAttribute.cs 1.2 kB

12345678910111213141516171819202122232425262728293031
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // EnvironmentSpecificFactAttribute.cs
  3. using Xunit;
  4. namespace AutoGen.Tests;
  5. /// <summary>
  6. /// A base class for environment-specific fact attributes.
  7. /// </summary>
  8. [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
  9. public abstract class EnvironmentSpecificFactAttribute : FactAttribute
  10. {
  11. private readonly string _skipMessage;
  12. /// <summary>
  13. /// Creates a new instance of the <see cref="EnvironmentSpecificFactAttribute" /> class.
  14. /// </summary>
  15. /// <param name="skipMessage">The message to be used when skipping the test marked with this attribute.</param>
  16. protected EnvironmentSpecificFactAttribute(string skipMessage)
  17. {
  18. _skipMessage = skipMessage ?? throw new ArgumentNullException(nameof(skipMessage));
  19. }
  20. public sealed override string Skip => IsEnvironmentSupported() ? string.Empty : _skipMessage;
  21. /// <summary>
  22. /// A method used to evaluate whether to skip a test marked with this attribute. Skips iff this method evaluates to false.
  23. /// </summary>
  24. protected abstract bool IsEnvironmentSupported();
  25. }