public static IMethodInfoProvider GetByName(this IMethodLister methodLister, string name) { var all = methodLister.ListAllMethods().Where( m => { string methodNamePart = Stringifier.GetMethodDeclarationString(m); return(methodNamePart != null && methodNamePart.Contains(name)); }).ToArray(); if (all.Length > 1) { throw new InvalidOperationException("More than one method with this name defined. Create unique method for your test case."); } return(all.FirstOrDefault()); }
private static IEnumerable <string> GetAllMethodsEx(this IMethodLister methodLister, Func <string, bool> except = null) { foreach (var info in methodLister.ListAllMethods()) { string method = Stringifier.GetMethodDeclarationString(info); // exclude compiler-generated lambda methods like "SomeTestType::<MethodWithLambdasInside>b__0(object actParam)" if (method == null) { continue; } if (except != null && except(method)) { continue; } yield return(method); } }