public void TestDefaultPageSizePickedUp() { MethodInfo actionMethod = FindMethod(typeof(Customer1), "SomeAction"); var actionPeer = new ActionSpecImmutable(null, null, null); new FallbackFacetFactory(0).Process(Reflector, actionMethod, MethodRemover, actionPeer); IFacet facet = actionPeer.GetFacet(typeof(IPageSizeFacet)); Assert.IsNotNull(facet); Assert.IsTrue(facet is PageSizeFacetDefault); var pageSizeFacet = (IPageSizeFacet)facet; Assert.AreEqual(20, pageSizeFacet.Value); AssertNoMethodsRemoved(); }
private IActionSpecImmutable[] FindActionMethods(IObjectSpecImmutable spec) { Log.Debug("Looking for action methods"); var actionSpecs = new List <IActionSpecImmutable>(); for (int i = 0; i < methods.Length; i++) { // careful in here - methods are being nulled out within the methods array as we iterate. if (methods[i] != null) { MethodInfo actionMethod = methods[i]; string fullMethodName = actionMethod.Name; if (!FacetFactorySet.Filters(actionMethod, reflector.ClassStrategy)) { Log.DebugFormat("Identified action {0}", actionMethod); methods[i] = null; Type[] parameterTypes = actionMethod.GetParameters().Select(parameterInfo => parameterInfo.ParameterType).ToArray(); // build action & its parameters IActionParameterSpecImmutable[] actionParams = parameterTypes.Select(pt => new ActionParameterSpecImmutable(GetSpecification(pt))).Cast <IActionParameterSpecImmutable>().ToArray(); IIdentifier identifier = new IdentifierImpl(metamodel, FullName, fullMethodName, actionMethod.GetParameters().ToArray()); var action = new ActionSpecImmutable(identifier, spec, actionParams); // Process facets on the action & parameters FacetFactorySet.Process(reflector, actionMethod, new IntrospectorMethodRemover(methods), action, FeatureType.Action); for (int l = 0; l < actionParams.Length; l++) { FacetFactorySet.ProcessParams(reflector, actionMethod, l, actionParams[l]); } if (actionMethod.ReturnType != typeof(void)) { reflector.LoadSpecification(actionMethod.ReturnType); } actionSpecs.Add(action); } } } return(actionSpecs.ToArray()); }