示例#1
0
        public static void VerifyResultsExistForWhere(object service, object context, string defaultSource, params string[] predicates)
        {
            IQueryable       source          = null;
            IServiceProvider serviceProvider = context as IServiceProvider;

            if (serviceProvider != null)
            {
                Prov.IDataServiceMetadataProvider dataProvider = (Prov.IDataServiceMetadataProvider)serviceProvider.GetService(typeof(Prov.IDataServiceMetadataProvider));
                if (dataProvider != null)
                {
                    Prov.ResourceSet resourceSet;
                    if (dataProvider.TryResolveResourceSet(defaultSource, out resourceSet))
                    {
                        Prov.IDataServiceQueryProvider queryProvider = (Prov.IDataServiceQueryProvider)serviceProvider.GetService(typeof(Prov.IDataServiceQueryProvider));
                        source = queryProvider.GetQueryRootForResourceSet(resourceSet);
                    }
                }
            }

            if (source == null)
            {
                source = (IQueryable)context.GetType().GetProperty(defaultSource).GetValue(context, null);
            }

            TestUtil.RunCombinations(predicates, (predicate) =>
            {
                IQueryable actualSource = source;
                string actualPredicate  = predicate;
                int separatorIndex      = predicate.IndexOf('|');
                string sourceName       = defaultSource;
                if (separatorIndex != -1)
                {
                    sourceName      = predicate.Substring(0, separatorIndex);
                    actualSource    = (IQueryable)context.GetType().GetProperty(sourceName).GetValue(context, null);
                    actualPredicate = predicate.Substring(separatorIndex + 1);
                }

                Trace.WriteLine("Verifying results exist for predicate [" + actualPredicate + "]");

                Prov.ResourceType resourceType = GetResourceTypeForContainer(service, sourceName);
                object resourceSet             = GetResourceSetWrapper(service, sourceName);
                Assert.IsNotNull(resourceType, "Should be able to find the container and its corresponding type");

                IQueryable result = InvokeWhere(service, GetRequestDescription(resourceType, resourceSet, defaultSource), actualSource, actualPredicate);
                bool found        = false;
                foreach (object o in result)
                {
                    found = true;
                    break;
                }

                Assert.IsTrue(found, "Results not found for predicate [" + actualPredicate + "]");
            });
        }
示例#2
0
        private static Prov.ResourceType GetResourceType(object service, string typename)
        {
            Prov.IDataServiceMetadataProvider provider = GetProvider(service);
            Prov.ResourceType type;
            if (provider.TryResolveResourceType(typename, out type))
            {
                return(type);
            }

            return(null);
        }
示例#3
0
        private static Prov.ResourceSet GetResourceSet(object service, string name)
        {
            Prov.IDataServiceMetadataProvider provider = GetProvider(service);
            Prov.ResourceSet resourceSet;
            if (provider.TryResolveResourceSet(name, out resourceSet))
            {
                return(resourceSet);
            }

            return(null);
        }
示例#4
0
        private static void SetUpActionWithLargeParameterPayload(MyDSPActionProvider actionProvider, Provider.IDataServiceMetadataProvider metadata, Provider.ResourceType bindingParameterType)
        {
            List <Provider.ServiceActionParameter> parameters = new List <Provider.ServiceActionParameter>();

            if (bindingParameterType != null)
            {
                parameters.Add(new Provider.ServiceActionParameter("bindingParam", bindingParameterType));
            }

            int j = 0;

            for (int i = 0; i < ActionTestsWithLargePayload.ParameterPayloadSize; ++i)
            {
                string pName = "p_int_" + j++;
                parameters.Add(new Provider.ServiceActionParameter(pName, Provider.ResourceType.GetPrimitiveResourceType(typeof(Int32))));

                pName = "p_string_" + j++;
                parameters.Add(new Provider.ServiceActionParameter(pName, Provider.ResourceType.GetPrimitiveResourceType(typeof(string))));

                pName = "p_double_" + j++;
                parameters.Add(new Provider.ServiceActionParameter(pName, Provider.ResourceType.GetPrimitiveResourceType(typeof(double))));

                pName = "p_datetimeoffset_" + j++;
                parameters.Add(new Provider.ServiceActionParameter(pName, Provider.ResourceType.GetPrimitiveResourceType(typeof(DateTimeOffset))));

                pName = "p_complex_" + j++;
                parameters.Add(new Provider.ServiceActionParameter(pName, ActionTestsWithLargePayload.ComplexType));
            }

            actionProvider.AddAction("ActionWithLargeParameterPayload", null, null, parameters, Provider.OperationParameterBindingKind.Sometimes, null, null);
        }
示例#5
0
        private static void SetupLargeNumberOfActions(MyDSPActionProvider actionProvider, Provider.IDataServiceMetadataProvider metadata, Provider.ResourceType bindingParameterType)
        {
            List <Provider.ServiceActionParameter> parameters = new List <Provider.ServiceActionParameter>();

            if (bindingParameterType != null)
            {
                parameters.Add(new Provider.ServiceActionParameter("bindingParam", bindingParameterType));
            }

            for (int i = 0; i < NumberOfActions; ++i)
            {
                actionProvider.AddAction("Action_" + i, null, null, parameters, Provider.OperationParameterBindingKind.Sometimes, null, null);
            }
        }
示例#6
0
        private static void SetUpActionWithLargeCollectionParameterPayload(MyDSPActionProvider actionProvider, Provider.IDataServiceMetadataProvider metadata, Provider.ResourceType bindingParameterType)
        {
            List <Provider.ServiceActionParameter> parameters = new List <Provider.ServiceActionParameter>();

            if (bindingParameterType != null)
            {
                parameters.Add(new Provider.ServiceActionParameter("bindingParam", bindingParameterType));
            }

            parameters.Add(new Provider.ServiceActionParameter("collectionParameter", Provider.ResourceType.GetCollectionResourceType(Provider.ResourceType.GetPrimitiveResourceType(typeof(string)))));
            actionProvider.AddAction("ActionWithLargeCollectionParameterPayload", null, null, parameters, Provider.OperationParameterBindingKind.Sometimes, null, null);
        }