I would like to use FluentAssertions to test for all methods that are not decorated with the NonActionAttribute. (This will reduce the set of action methods automatically generated as placeholders by T4MVC.)
My specific problem is with chaining together MethodInfoSelector methods. I would like to write something like this:
public MethodInfoSelector AllActionMethods() {
return TestControllerType.Methods()
.ThatReturn<ActionResult>()
.ThatAreNotDecoratedWith<NonActionAttribute>();
}
public static MethodInfoSelector ThatAreNotDecoratedWith<TAttribute>(this IEnumerable<MethodInfo> selectedMethods) {
return (MethodInfoSelector)(selectedMethods.Where(method => !method.GetCustomAttributes(false).OfType<TAttribute>().Any())); // this cast fails
}
Either the cast fails, or if I convert my results to IEnumberable I can't chain additional MethodInfoSelector methods.
I would appreciate any help with either how to generate a MethodInfoSelector or a different approach to the underlying problem of listing methods that do not have a specific attribute.