TestRunCallbackAttribute.cs 730 B

123456789101112131415161718192021222324
  1. using System;
  2. namespace UnityEngine.TestRunner
  3. {
  4. [AttributeUsage(AttributeTargets.Assembly)]
  5. public class TestRunCallbackAttribute : Attribute
  6. {
  7. private Type m_Type;
  8. public TestRunCallbackAttribute(Type type)
  9. {
  10. var interfaceType = typeof(ITestRunCallback);
  11. if (!interfaceType.IsAssignableFrom(type))
  12. {
  13. throw new ArgumentException(string.Format("Type provided to {0} does not implement {1}", this.GetType().Name, interfaceType.Name));
  14. }
  15. m_Type = type;
  16. }
  17. internal ITestRunCallback ConstructCallback()
  18. {
  19. return Activator.CreateInstance(m_Type) as ITestRunCallback;
  20. }
  21. }
  22. }