Write yourself two helper functions (using reflection) along these lines:
public static bool HasAttribute(TypeInfo info, Type attributeType) public static bool HasAttribute(TypeInfo info, string methodName, Type attributeType)
Then you can write the tests as follows:
Assert.IsTrue(HasAttribute(myType, expectedAttribute));
This way you do not need to use if / else / foreach or other logic in your testing methods. Thus, they become much more understandable and readable.
NTN
Thomas
Thomas weller
source share