Exemplo n.º 1
0
        public void TestGetRequestForQuery()
        {
            RestRequest request = RestRequest.GetRequestForQuery(TEST_API_VERSION, TEST_QUERY);

            Assert.AreEqual(HttpMethod.Get, request.Method, "Wrong method");
            Assert.AreEqual("/services/data/" + TEST_API_VERSION + "/query?q=" + TEST_QUERY, request.Path, "Wrong path");
            Assert.IsNull(request.RequestBody, "Wrong request body");
            Assert.AreEqual(request.AdditionalHeaders.Count, 0);
        }
Exemplo n.º 2
0
        public async Task TestQueryWithUnAuthenticatedClient()
        {
            IdName newAccountIdName = await CreateAccount();

            RestResponse response =
                await
                _unauthenticatedRestClient.SendAsync(RestRequest.GetRequestForQuery(TestCredentials.API_VERSION,
                                                                                    "select name from account where id = '" + newAccountIdName.Id + "'"));

            Assert.AreEqual(response.StatusCode.ToString().ToLower(), HttpStatusCode.Unauthorized.ToString().ToLower());
        }
        public void TestQuery()
        {
            IdName       newAccountIdName = CreateAccount();
            RestResponse response         = _restClient.SendSync(RestRequest.GetRequestForQuery(TestCredentials.API_VERSION, "select name from account where id = '" + newAccountIdName.Id + "'"));

            CheckResponse(response, HttpStatusCode.OK, false);
            JObject jsonResponse = response.AsJObject;

            CheckKeys(jsonResponse, "done", "totalSize", "records");
            Assert.AreEqual(1, jsonResponse["totalSize"], "Expected one row");
            Assert.AreEqual(newAccountIdName.Name, jsonResponse["records"][0]["Name"], "Wrong row returned");
        }
        public async Task TestQuery()
        {
            IdName newAccountIdName = await CreateAccount();

            var response =
                await
                _restClient.SendAsync(RestRequest.GetRequestForQuery(new TestCredentials().ApiVersion,
                                                                     "select name from account where id = '" + newAccountIdName.Id + "'"));

            CheckResponse(response, HttpStatusCode.OK, false);
            JObject jsonResponse = response.AsJObject;

            CheckKeys(jsonResponse, "done", "totalSize", "records");
            Assert.AreEqual(1, jsonResponse["totalSize"], "Expected one row");
            Assert.AreEqual(newAccountIdName.Name, jsonResponse["records"][0]["Name"], "Wrong row returned");
        }