PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/src/NUnit/framework/Attributes/TestCaseSourceAttribute.cs

#
C# | 59 lines | 27 code | 6 blank | 26 comment | 0 complexity | 7edc0765a7269adfda7bda2dd09d99dc MD5 | raw file
Possible License(s): GPL-2.0
  1. // ****************************************************************
  2. // Copyright 2008, Charlie Poole
  3. // This is free software licensed under the NUnit license. You may
  4. // obtain a copy of the license at http://nunit.org
  5. // ****************************************************************
  6. using System;
  7. namespace NUnit.Framework
  8. {
  9. /// <summary>
  10. /// FactoryAttribute indicates the source to be used to
  11. /// provide test cases for a test method.
  12. /// </summary>
  13. [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
  14. public class TestCaseSourceAttribute : Attribute
  15. {
  16. private readonly string sourceName;
  17. private readonly Type sourceType;
  18. /// <summary>
  19. /// Construct with the name of the factory - for use with languages
  20. /// that don't support params arrays.
  21. /// </summary>
  22. /// <param name="sourceName">An array of the names of the factories that will provide data</param>
  23. public TestCaseSourceAttribute(string sourceName)
  24. {
  25. this.sourceName = sourceName;
  26. }
  27. /// <summary>
  28. /// Construct with a Type and name - for use with languages
  29. /// that don't support params arrays.
  30. /// </summary>
  31. /// <param name="sourceType">The Type that will provide data</param>
  32. /// <param name="sourceName">The name of the method, property or field that will provide data</param>
  33. public TestCaseSourceAttribute(Type sourceType, string sourceName)
  34. {
  35. this.sourceType = sourceType;
  36. this.sourceName = sourceName;
  37. }
  38. /// <summary>
  39. /// The name of a the method, property or fiend to be used as a source
  40. /// </summary>
  41. public string SourceName
  42. {
  43. get { return sourceName; }
  44. }
  45. /// <summary>
  46. /// A Type to be used as a source
  47. /// </summary>
  48. public Type SourceType
  49. {
  50. get { return sourceType; }
  51. }
  52. }
  53. }