PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/NUnit/framework/Attributes/IncludeExcludeAttributes.cs

#
C# | 106 lines | 42 code | 11 blank | 53 comment | 0 complexity | 48179e5938d0efd486a7cfd02f155699 MD5 | raw file
Possible License(s): GPL-2.0
  1. // ****************************************************************
  2. // Copyright 2007, 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. /// Abstract base for Attributes that are used to include tests
  11. /// in the test run based on environmental settings.
  12. /// </summary>
  13. public abstract class IncludeExcludeAttribute : Attribute
  14. {
  15. private string include;
  16. private string exclude;
  17. private string reason;
  18. /// <summary>
  19. /// Constructor with no included items specified, for use
  20. /// with named property syntax.
  21. /// </summary>
  22. public IncludeExcludeAttribute() { }
  23. /// <summary>
  24. /// Constructor taking one or more included items
  25. /// </summary>
  26. /// <param name="include">Comma-delimited list of included items</param>
  27. public IncludeExcludeAttribute( string include )
  28. {
  29. this.include = include;
  30. }
  31. /// <summary>
  32. /// Name of the item that is needed in order for
  33. /// a test to run. Multiple itemss may be given,
  34. /// separated by a comma.
  35. /// </summary>
  36. public string Include
  37. {
  38. get { return this.include; }
  39. set { include = value; }
  40. }
  41. /// <summary>
  42. /// Name of the item to be excluded. Multiple items
  43. /// may be given, separated by a comma.
  44. /// </summary>
  45. public string Exclude
  46. {
  47. get { return this.exclude; }
  48. set { this.exclude = value; }
  49. }
  50. /// <summary>
  51. /// The reason for including or excluding the test
  52. /// </summary>
  53. public string Reason
  54. {
  55. get { return reason; }
  56. set { reason = value; }
  57. }
  58. }
  59. /// <summary>
  60. /// PlatformAttribute is used to mark a test fixture or an
  61. /// individual method as applying to a particular platform only.
  62. /// </summary>
  63. [AttributeUsage(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Assembly, AllowMultiple=true, Inherited=false)]
  64. public class PlatformAttribute : IncludeExcludeAttribute
  65. {
  66. /// <summary>
  67. /// Constructor with no platforms specified, for use
  68. /// with named property syntax.
  69. /// </summary>
  70. public PlatformAttribute() { }
  71. /// <summary>
  72. /// Constructor taking one or more platforms
  73. /// </summary>
  74. /// <param name="platforms">Comma-deliminted list of platforms</param>
  75. public PlatformAttribute( string platforms ) : base( platforms ) { }
  76. }
  77. /// <summary>
  78. /// CultureAttribute is used to mark a test fixture or an
  79. /// individual method as applying to a particular Culture only.
  80. /// </summary>
  81. [AttributeUsage(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
  82. public class CultureAttribute : IncludeExcludeAttribute
  83. {
  84. /// <summary>
  85. /// Constructor with no cultures specified, for use
  86. /// with named property syntax.
  87. /// </summary>
  88. public CultureAttribute() { }
  89. /// <summary>
  90. /// Constructor taking one or more cultures
  91. /// </summary>
  92. /// <param name="cultures">Comma-deliminted list of cultures</param>
  93. public CultureAttribute( string cultures ) : base( cultures ) { }
  94. }
  95. }