Esempio n. 1
0
        public void Default_Ctor_Selects_Nothing_And_SelectColumns_IsNotNull()
        {
            var soql = new SoqlQuery();

            StringAssert.DoesNotContain(SoqlQuery.SelectKey, soql.ToString());
            Assert.IsNotNull(soql.SelectColumns);
        }
Esempio n. 2
0
        /// <summary>
        /// Create a Uri for querying the specified resource on the specified Socrata host, using the specified SoqlQuery object.
        /// </summary>
        /// <param name="socrataHost">The Socrata host to target.</param>
        /// <param name="resourceId">The identifier (4x4) for a resource on the Socrata host to target.</param>
        /// <param name="soqlQuery">A SoqlQuery object to use for querying.</param>
        /// <returns>A query Uri for the specified resource on the specified Socrata host.</returns>
        public static Uri ForQuery(string socrataHost, string resourceId, SoqlQuery soqlQuery)
        {
            if (String.IsNullOrEmpty(socrataHost))
            {
                throw new ArgumentException("socrataHost", "Must provide a Socrata host to target.");
            }

            if (FourByFour.IsNotValid(resourceId))
            {
                throw new ArgumentOutOfRangeException("resourceId", "The provided resourceId is not a valid Socrata (4x4) resource identifier.");
            }

            if (soqlQuery == null)
            {
                throw new ArgumentNullException("soqlQuery", "Must provide a valid SoqlQuery object");
            }

            string url = metadataUrl(socrataHost, resourceId).Replace("views", "resource");

            string queryUrl = Uri.EscapeUriString(String.Format("{0}?{1}", url, soqlQuery.ToString()));

            return(new Uri(queryUrl));
        }
Esempio n. 3
0
        public void ForQuery_With_Valid_Arguments_Creates_Query_Uri()
        {
            SoqlQuery soqlQuery = new SoqlQuery();

            var uri = SodaUri.ForQuery(StringMocks.Host, StringMocks.ResourceId, soqlQuery);

            StringAssert.AreEqualIgnoringCase(String.Format("/resource/{0}", StringMocks.ResourceId), uri.LocalPath);
            StringAssert.AreEqualIgnoringCase(String.Format("?{0}", Uri.EscapeUriString(soqlQuery.ToString())), uri.Query);
        }
Esempio n. 4
0
        public void ForQuery_With_Valid_Arguments_Creates_Query_Uri()
        {
            SoqlQuery soqlQuery = new SoqlQuery();

            var uri = SodaUri.ForQuery(StringMocks.Host, StringMocks.ResourceId, soqlQuery);

            StringAssert.AreEqualIgnoringCase(String.Format("/resource/{0}", StringMocks.ResourceId), uri.LocalPath);
            StringAssert.AreEqualIgnoringCase(String.Format("?{0}", Uri.EscapeUriString(soqlQuery.ToString())), uri.Query);
        }
Esempio n. 5
0
        /// <summary>
        /// Create a Uri for querying the specified resource on the specified Socrata host, using the specified SoqlQuery object.
        /// </summary>
        /// <param name="socrataHost">The Socrata host to target.</param>
        /// <param name="resourceId">The identifier (4x4) for a resource on the Socrata host to target.</param>
        /// <param name="soqlQuery">A SoqlQuery object to use for querying.</param>
        /// <returns>A query Uri for the specified resource on the specified Socrata host.</returns>
        public static Uri ForQuery(string socrataHost, string resourceId, SoqlQuery soqlQuery)
        {
            if (String.IsNullOrEmpty(socrataHost))
                throw new ArgumentException("socrataHost", "Must provide a Socrata host to target.");

            if (FourByFour.IsNotValid(resourceId))
                throw new ArgumentOutOfRangeException("resourceId", "The provided resourceId is not a valid Socrata (4x4) resource identifier.");

            if (soqlQuery == null)
                throw new ArgumentNullException("soqlQuery", "Must provide a valid SoqlQuery object");

            string url = metadataUrl(socrataHost, resourceId).Replace("views", "resource");

            string queryUrl = Uri.EscapeUriString(String.Format("{0}?{1}", url, soqlQuery.ToString()));

            return new Uri(queryUrl);
        }