~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Analysis/UnitTesting/Src/TestAttributeName.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using ICSharpCode.SharpDevelop.Dom;
 
6
 
 
7
namespace ICSharpCode.UnitTesting
 
8
{
 
9
        public class NUnitTestAttributeName
 
10
        {
 
11
                string name = String.Empty;
 
12
                string qualifiedName = String.Empty;
 
13
                string fullyQualifiedName = String.Empty;
 
14
                StringComparer nameComparer;
 
15
                
 
16
                /// <summary>
 
17
                /// Creates a new instance of the NUnit Test Attribute class.
 
18
                /// </summary>
 
19
                /// <param name="name">The name of the attribute (e.g. Test) not
 
20
                /// the full name of the attribute (e.g. TestAttribute).</param>
 
21
                /// <param name="nameComparer">The string comparer to use
 
22
                /// when comparing attribute names.</param>
 
23
                public NUnitTestAttributeName(string name, StringComparer nameComparer)
 
24
                {
 
25
                        this.name = name;
 
26
                        this.nameComparer = nameComparer;
 
27
                        qualifiedName = String.Concat(name, "Attribute");
 
28
                        fullyQualifiedName = String.Concat("NUnit.Framework.", name, "Attribute");
 
29
                }
 
30
                
 
31
                /// <summary>
 
32
                /// Determines whether the specified attribute name is a
 
33
                /// match to this attribute.
 
34
                /// </summary>
 
35
                public bool IsEqual(string attributeName)
 
36
                {
 
37
                        if (nameComparer.Equals(attributeName, name) || 
 
38
                                nameComparer.Equals(attributeName, qualifiedName) ||
 
39
                                nameComparer.Equals(attributeName, fullyQualifiedName)) {
 
40
                                return true;
 
41
                        }
 
42
                        return false;
 
43
                }
 
44
                
 
45
                public bool IsEqual(IAttribute attribute)
 
46
                {
 
47
                        return IsEqual(attribute.AttributeType.FullyQualifiedName);
 
48
                }
 
49
        }
 
50
}