importing messaging-2008 branch to trunk [continued]
[mono.git] / mcs / nunit24 / NUnitFramework / framework / CategoryAttribute.cs
1 // ****************************************************************\r
2 // This is free software licensed under the NUnit license. You\r
3 // may obtain a copy of the license as well as information regarding\r
4 // copyright ownership at http://nunit.org/?p=license&r=2.4.\r
5 // ****************************************************************\r
6 \r
7 using System;\r
8 \r
9 namespace NUnit.Framework\r
10 {\r
11         /// <summary>\r
12         /// Attribute used to apply a category to a test\r
13         /// </summary>\r
14         [AttributeUsage(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Assembly, AllowMultiple=true)]\r
15         public class CategoryAttribute : Attribute\r
16         {\r
17                 /// <summary>\r
18                 /// The name of the category\r
19                 /// </summary>\r
20                 protected string categoryName;\r
21 \r
22                 /// <summary>\r
23                 /// Construct attribute for a given category\r
24                 /// </summary>\r
25                 /// <param name="name">The name of the category</param>\r
26                 public CategoryAttribute(string name)\r
27                 {\r
28                         this.categoryName = name;\r
29                 }\r
30 \r
31                 /// <summary>\r
32                 /// Protected constructor uses the Type name as the name\r
33                 /// of the category.\r
34                 /// </summary>\r
35                 protected CategoryAttribute()\r
36                 {\r
37                         this.categoryName = this.GetType().Name;\r
38                         if ( categoryName.EndsWith( "Attribute" ) )\r
39                                 categoryName = categoryName.Substring( 0, categoryName.Length - 9 );\r
40                 }\r
41 \r
42                 /// <summary>\r
43                 /// The name of the category\r
44                 /// </summary>\r
45                 public string Name \r
46                 {\r
47                         get { return categoryName; }\r
48                 }\r
49         }\r
50 }\r