Ejemplo n.º 1
0
        private async void Cleanup()
        {
            try
            {
                RestResponse searchResponse =
                    await
                    _restClient.SendAsync(RestRequest.GetRequestForSearch(TestCredentials.API_VERSION,
                                                                          "find {" + ENTITY_NAME_PREFIX + "}"));

                JArray matchingRows = searchResponse.AsJArray;
                for (int i = 0; i < matchingRows.Count; i++)
                {
                    var matchingRow     = (JObject)matchingRows[i];
                    var matchingRowType = (string)matchingRow["attributes"]["type"];
                    var matchingRowId   = (string)matchingRow["Id"];
                    Debug.WriteLine("Trying to delete {0}", matchingRowId);
                    await
                    _restClient.SendAsync(RestRequest.GetRequestForDelete(TestCredentials.API_VERSION,
                                                                          matchingRowType, matchingRowId));

                    Debug.WriteLine("Successfully deleted {0}", matchingRowId);
                }
            }
            catch
            {
                // We tried our best :-(
            }
        }
Ejemplo n.º 2
0
        public void TestGetRequestForSeach()
        {
            RestRequest request = RestRequest.GetRequestForSearch(TEST_API_VERSION, TEST_SEARCH);

            Assert.AreEqual(RestMethod.GET, request.Method, "Wrong method");
            Assert.AreEqual(ContentType.NONE, request.ContentType, "Wrong content type");
            Assert.AreEqual("/services/data/" + TEST_API_VERSION + "/search?q=" + TEST_SEARCH, request.Path, "Wrong path");
            Assert.IsNull(request.Body, "Wrong request body");
            Assert.IsNull(request.AdditionalHeaders, "Wrong additional headers");
        }
Ejemplo n.º 3
0
        public void TestGetRequestForSeach()
        {
            RestRequest request = RestRequest.GetRequestForSearch(TEST_API_VERSION, TEST_SEARCH);

            Assert.AreEqual(HttpMethod.Get, request.Method, "Wrong method");
            Assert.AreEqual(ContentTypeValues.None, request.ContentType, "Wrong content type");
            Assert.AreEqual("/services/data/" + TEST_API_VERSION + "/search?q=" + TEST_SEARCH, request.Path,
                            "Wrong path");
            Assert.IsNull(request.RequestBody, "Wrong request body");
            Assert.AreEqual(request.AdditionalHeaders.Count, 0);
        }
Ejemplo n.º 4
0
        public async Task TestSearchWithUnAuthenticatedClient()
        {
            IdName newAccountIdName = await CreateAccount();

            RestResponse response =
                await
                _unauthenticatedRestClient.SendAsync(RestRequest.GetRequestForSearch(TestCredentials.API_VERSION,
                                                                                     "find {" + newAccountIdName.Name + "}"));

            Assert.AreEqual(response.StatusCode.ToString().ToLower(), HttpStatusCode.Unauthorized.ToString().ToLower());
        }
        public void TestSearch()
        {
            IdName       newAccountIdName = CreateAccount();
            RestResponse response         = _restClient.SendSync(RestRequest.GetRequestForSearch(TestCredentials.API_VERSION, "find {" + newAccountIdName.Name + "}"));

            CheckResponse(response, HttpStatusCode.OK, true);
            JArray matchingRows = response.AsJArray;

            Assert.AreEqual(1, matchingRows.Count, "Expected one row");
            JObject matchingRow = (JObject)matchingRows[0];

            CheckKeys(matchingRow, "attributes", "Id");
            Assert.AreEqual(newAccountIdName.Id, matchingRow["Id"], "Wrong row returned");
        }
        public async Task TestSearch()
        {
            IdName newAccountIdName = await CreateAccount();

            var response =
                await
                _restClient.SendAsync(RestRequest.GetRequestForSearch(new TestCredentials().ApiVersion,
                                                                      "find {" + newAccountIdName.Name + "}"));

            CheckResponse(response, HttpStatusCode.OK, true);
            JArray matchingRows = response.AsJArray;

            Assert.AreEqual(1, matchingRows.Count, "Expected one row");
            var matchingRow = (JObject)matchingRows[0];

            CheckKeys(matchingRow, "attributes", "Id");
            Assert.AreEqual(newAccountIdName.Id, matchingRow["Id"], "Wrong row returned");
        }