Example #1
0
 private void CheckDefaultFacet(MethodInfo defaultMethod, INakedObjectActionParamPeer parameter) {
     IFacet facet = parameter.GetFacet(typeof (IActionDefaultsFacet));
     Assert.IsNotNull(facet);
     Assert.IsTrue(facet is ActionDefaultsFacetViaMethod);
     Assert.AreEqual(defaultMethod, ((ActionDefaultsFacetViaMethod) facet).GetMethod());
     Assert.IsTrue(methodRemover.GetRemoveMethodMethodCalls().Contains(defaultMethod));
 }
        private void FindAndRemoveParametersAutoCompleteMethod(IMethodRemover methodRemover, Type type, string capitalizedName, Type[] paramTypes, INakedObjectActionParamPeer[] parameters) {
            for (int i = 0; i < paramTypes.Length; i++) {
                // only support on strings and reference types 

                if (paramTypes[i].IsClass || paramTypes[i].IsInterface) {
                    Type returnType = typeof (IQueryable<>).MakeGenericType(paramTypes[i]);

                    MethodInfo method = FindMethod(type,
                                                   MethodType.Object,
                                                   PrefixesAndRecognisedMethods.AutoCompletePrefix + i + capitalizedName,
                                                   returnType,
                                                   new[] {typeof (string)});

                    if (method != null) {
                        var pageSizeAttr = method.GetCustomAttribute<PageSizeAttribute>();
                        var minLengthAttr = (MinLengthAttribute) Attribute.GetCustomAttribute(method.GetParameters().First(), typeof (MinLengthAttribute));

                        int pageSize = pageSizeAttr != null ? pageSizeAttr.Value : 0; // default to 0 ie system default
                        int minLength = minLengthAttr != null ? minLengthAttr.Length : 0;

                        // deliberately not removing both if duplicate to show that method  is duplicate
                        RemoveMethod(methodRemover, method);

                        // add facets directly to parameters, not to actions 
                        FacetUtils.AddFacet(new AutoCompleteFacetViaMethod(method, pageSize, minLength, parameters[i]));
                        AddOrAddToExecutedWhereFacet(method, parameters[i]);
                    }
                }
            }
        }
 public OneToManyActionParameterImpl(int index, INakedObjectAction actionImpl, INakedObjectActionParamPeer peer)
     : base(index, actionImpl, peer) {}
Example #4
0
 private void CheckAutoCompleteFacetIsNull(MethodInfo autoCompleteMethod, INakedObjectActionParamPeer parameter) {
     IFacet facet = parameter.GetFacet(typeof (IAutoCompleteFacet));
     Assert.IsNull(facet);
     Assert.IsFalse(methodRemover.GetRemoveMethodMethodCalls().Contains(autoCompleteMethod));
 }
Example #5
0
        private void CheckAutoCompleteFacet(MethodInfo autoCompleteMethod, INakedObjectActionParamPeer parameter, int pageSize, int minLength) {
            IFacet facet = parameter.GetFacet(typeof (IAutoCompleteFacet));
            Assert.IsNotNull(facet);
            Assert.IsTrue(facet is AutoCompleteFacetViaMethod);
            var acf = (AutoCompleteFacetViaMethod) facet;
            Assert.AreEqual(autoCompleteMethod, acf.GetMethod());
            Assert.IsTrue(methodRemover.GetRemoveMethodMethodCalls().Contains(autoCompleteMethod));

            Assert.AreEqual(pageSize, acf.PageSize);
            Assert.AreEqual(minLength, acf.MinLength);
        }
Example #6
0
 public DotNetNakedObjectActionPeer(IIdentifier identifier, INakedObjectActionParamPeer[] parameters)
     : base(identifier) {
     this.parameters = parameters;
 }
 public NakedObjectActionParameterParseable(int index, INakedObjectAction action, INakedObjectActionParamPeer peer)
     : base(index, action, peer) {}