/// <summary> /// Determines whether the class is a test fixture. A class /// is considered to be a test class if it contains a TestFixture attribute. /// </summary> public bool IsTestClass(IClass c) { if (c == null) { return(false); } if (c.IsAbstract) { return(false); } StringComparer nameComparer = GetNameComparer(c); if (nameComparer != null) { NUnitTestAttributeName testAttributeName = new NUnitTestAttributeName("TestFixture", nameComparer); foreach (IAttribute attribute in c.Attributes) { if (testAttributeName.IsEqual(attribute)) { return(true); } } } while (c != null) { if (HasTestMethod(c)) { return(true); } c = c.BaseClass; } return(false); }
/// <summary> /// Determines whether the method is a test method. A method /// is considered to be a test method if it contains the NUnit Test attribute. /// If the method has parameters it cannot be a test method. /// </summary> public bool IsTestMethod(IMember member) { if (member == null) { return(false); } StringComparer nameComparer = GetNameComparer(member.DeclaringType); if (nameComparer != null) { NUnitTestAttributeName testAttribute = new NUnitTestAttributeName("Test", nameComparer); foreach (IAttribute attribute in member.Attributes) { if (testAttribute.IsEqual(attribute)) { IMethod method = (IMethod)member; if (method.Parameters.Count == 0) { return(true); } } } } return(false); }
/// <summary> /// Determines whether the class is a test fixture. A class /// is considered to be a test class if it contains a TestFixture attribute. /// </summary> public bool IsTestClass(IClass c) { StringComparer nameComparer = GetNameComparer(c); if (nameComparer != null) { NUnitTestAttributeName testAttributeName = new NUnitTestAttributeName("TestFixture", nameComparer); foreach (IAttribute attribute in c.Attributes) { if (testAttributeName.IsEqual(attribute)) { return true; } } } return false; }
/// <summary> /// Determines whether the class is a test fixture. A class /// is considered to be a test class if it contains a TestFixture attribute. /// </summary> public bool IsTestClass(IClass c) { StringComparer nameComparer = GetNameComparer(c); if (nameComparer != null) { NUnitTestAttributeName testAttributeName = new NUnitTestAttributeName("TestFixture", nameComparer); foreach (IAttribute attribute in c.Attributes) { if (testAttributeName.IsEqual(attribute)) { return(true); } } } return(false); }
/// <summary> /// Determines whether the class is a test fixture. A class /// is considered to be a test class if it contains a TestFixture attribute. /// </summary> public bool IsTestClass(IClass c) { if (c == null) return false; if (c.IsAbstract) return false; StringComparer nameComparer = GetNameComparer(c); if (nameComparer != null) { NUnitTestAttributeName testAttributeName = new NUnitTestAttributeName("TestFixture", nameComparer); foreach (IAttribute attribute in c.Attributes) { if (testAttributeName.IsEqual(attribute)) { return true; } } } while (c != null) { if (HasTestMethod(c)) return true; c = c.BaseClass; } return false; }
/// <summary> /// Determines whether the method is a test method. A method /// is considered to be a test method if it contains the NUnit Test attribute. /// If the method has parameters it cannot be a test method. /// </summary> public bool IsTestMethod(IMember member) { if (member == null) { return false; } StringComparer nameComparer = GetNameComparer(member.DeclaringType); if (nameComparer != null) { NUnitTestAttributeName testAttribute = new NUnitTestAttributeName("Test", nameComparer); foreach (IAttribute attribute in member.Attributes) { if (testAttribute.IsEqual(attribute)) { IMethod method = (IMethod)member; if (method.Parameters.Count == 0) { return true; } } } } return false; }
static bool IsTestMethod(IMethod method) { var nameComparer = GetNameComparer(method.DeclaringType); if (nameComparer != null) { var testAttribute = new NUnitTestAttributeName("Test", nameComparer); foreach (IAttribute attribute in method.Attributes) { if (testAttribute.IsEqual(attribute)) { if (method.Parameters.Count == 0) { return true; } } } } return false; }