Exemplo n.º 1
0
        public void HydrateFilteringQuery_MultipleValues_ExpectedQuery()
        {
            ClientRequestParameters parameters = new ClientRequestParameters()
            {
                Filtering = new List <ClientRequestFiltering>
                {
                    new ClientRequestFiltering()
                    {
                        Property = "testproperty1",
                        Operator = FilteringOperator.IN,
                        Value    = new string[] { "5", "6" }
                    }
                }
            };

            var request = new ClientRequest()
            {
                Parameters = parameters
            };

            request.HydrateFilteringQuery();

            Assert.IsTrue(request.Query.ContainsKey("testproperty1:in"));
            Assert.AreEqual("5,6", request.Query["testproperty1:in"]);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Composes a relative URI from given ClientRequest instance
        /// </summary>
        /// <param name="request">Instance of ClientRequest object</param>
        /// <returns></returns>
        protected virtual string ComposeUri(ClientRequest request)
        {
            request.HydratePaginationQuery();
            request.HydrateSortingQuery();
            request.HydrateFilteringQuery();

            string queryString = null;

            if (request.Query != null && request.Query.Count > 0)
            {
                List <string> queryStringList = new List <string>();
                foreach (KeyValuePair <string, string> query in request.Query)
                {
                    if (query.Value != null)
                    {
                        queryStringList.Add($"{query.Key}={query.Value}");
                    }
                    else
                    {
                        queryStringList.Add(query.Key);
                    }
                }

                queryString = "?" + string.Join("&", queryStringList);
            }

            return(request.Resource.TrimStart('/') + queryString);
        }
Exemplo n.º 3
0
        public void HydrateFilteringQuery_NullParameters_MissingFilteringQueryExpected()
        {
            var request = new ClientRequest()
            {
                Parameters = null
            };

            request.HydrateFilteringQuery();

            Assert.AreEqual(0, request.Query.Count);
        }
Exemplo n.º 4
0
        public void HydrateFilteringQuery_NoFilteringParameters_MissingFilteringQueryExpected()
        {
            var request = new ClientRequest()
            {
                Parameters = new ClientRequestParameters()
                {
                    Filtering = new List <ClientRequestFiltering>()
                }
            };

            request.HydrateFilteringQuery();

            Assert.AreEqual(0, request.Query.Count);
        }