public AuthorizeAttributeCacheTests() { Func <string, Type> getType = name => { Type t = Type.GetType("Telerik.Web.Mvc.Infrastructure.Implementation.Tests." + name + "Controller", false, true); return(t); }; controllerTypeCache = new Mock <IControllerTypeCache>(); controllerTypeCache.Setup(c => c.GetControllerTypes(It.IsAny <string>())).Returns((string t) => new List <Type> { getType(t) }); actionMethodCache = new Mock <IActionMethodCache>(); actionMethodCache.Setup(c => c.GetAllActionMethods(It.IsAny <RequestContext>(), It.IsAny <string>())).Returns((RequestContext r, string c) => getType(c).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).ToDictionary(m => m.Name, m => new List <MethodInfo> { m } as IList <MethodInfo>)); actionMethodCache.Setup(c => c.GetAllActionMethods(It.IsAny <Type>())).Returns((Type t) => t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).ToDictionary(m => m.Name, m => new List <MethodInfo> { m } as IList <MethodInfo>)); authorizeAttributeCache = new AuthorizeAttributeCache(new NoCache(), controllerTypeCache.Object, actionMethodCache.Object); }
public AuthorizeAttributeCacheTests() { Func<string, Type> getType = name => { Type t = Type.GetType("Telerik.Web.Mvc.Infrastructure.Implementation.Tests." + name + "Controller", false, true); return t; }; controllerTypeCache = new Mock<IControllerTypeCache>(); controllerTypeCache.Setup(c => c.GetControllerTypes(It.IsAny<string>())).Returns((string t) => new List<Type>{ getType(t)}); actionMethodCache = new Mock<IActionMethodCache>(); actionMethodCache.Setup(c => c.GetAllActionMethods(It.IsAny<RequestContext>(), It.IsAny<string>())).Returns((RequestContext r, string c) => getType(c).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).ToDictionary(m => m.Name, m => new List<MethodInfo>{ m } as IList<MethodInfo>)); actionMethodCache.Setup(c => c.GetAllActionMethods(It.IsAny<Type>())).Returns((Type t) => t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).ToDictionary(m => m.Name, m => new List<MethodInfo> { m } as IList<MethodInfo>)); authorizeAttributeCache = new AuthorizeAttributeCache(new NoCache(), controllerTypeCache.Object, actionMethodCache.Object); }