Sorry if this is a stupid noob question please be gentle with me I\'m trying to learn...
I want to test against the attribute methods of things like models and controlle
You can check whether a method has a particular attribute by doing this:
typeof(Controller).GetMethod("MethodName").GetAttributes().Any();
In terms of the extension method itself, provided that you're looking for an extension method on the Controller type, how about something like this:
public static bool HasAttribute(this Controller controller, string methodName)
{
return controller.GetType().GetMethod(methodName).GetCustomAttributes(typeof(A), true).Any();
}
Remember, extension methods are invoked on an instance, so to use this you still need an instance of Controller:
var controller = new Controller();
Assert.IsTrue(controller.HasAttribute("Method1"));