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

TestPlayerBuildModifierAttribute.cs 1.3KB

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. namespace UnityEditor.TestTools
  3. {
  4. /// <summary>
  5. /// The `TestPlayerBuildModifierAttribute` attribute can be applied to test assemblies (will affect every test in the assembly).
  6. /// </summary>
  7. [AttributeUsage(AttributeTargets.Assembly)]
  8. public class TestPlayerBuildModifierAttribute : Attribute
  9. {
  10. private Type m_Type;
  11. /// <summary>
  12. /// Initializes and returns an instance of TestPlayerBuildModifierAttribute or throws an <see cref="ArgumentException"/>.
  13. /// </summary>
  14. /// <param name="type"></param>
  15. /// <exception cref="ArgumentException">Throws a <see cref="ArgumentException"/> if the type provided does not implemented the `ITestPlayerBuildModifier` interface. </exception>
  16. public TestPlayerBuildModifierAttribute(Type type)
  17. {
  18. var interfaceType = typeof(ITestPlayerBuildModifier);
  19. if (!interfaceType.IsAssignableFrom(type))
  20. {
  21. throw new ArgumentException(string.Format("Type provided to {0} does not implement {1}", this.GetType().Name, interfaceType.Name));
  22. }
  23. m_Type = type;
  24. }
  25. internal ITestPlayerBuildModifier ConstructModifier()
  26. {
  27. return Activator.CreateInstance(m_Type) as ITestPlayerBuildModifier;
  28. }
  29. }
  30. }