示例#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 :-(
            }
        }
示例#2
0
        public void TestGetRequestForDelete()
        {
            RestRequest request = RestRequest.GetRequestForDelete(TEST_API_VERSION, TEST_OBJECT_TYPE, TEST_OBJECT_ID);

            Assert.AreEqual(RestMethod.DELETE, request.Method, "Wrong method");
            Assert.AreEqual(ContentType.NONE, request.ContentType, "Wrong content type");
            Assert.AreEqual("/services/data/" + TEST_API_VERSION + "/sobjects/" + TEST_OBJECT_TYPE + "/" + TEST_OBJECT_ID, request.Path, "Wrong path");
            Assert.IsNull(request.Body, "Wrong request body");
            Assert.IsNull(request.AdditionalHeaders, "Wrong additional headers");
        }
示例#3
0
        public void TestGetRequestForDelete()
        {
            RestRequest request = RestRequest.GetRequestForDelete(TEST_API_VERSION, TEST_OBJECT_TYPE, TEST_OBJECT_ID);

            Assert.AreEqual(HttpMethod.Delete, request.Method, "Wrong method");
            Assert.AreEqual(ContentTypeValues.None, request.ContentType, "Wrong content type");
            Assert.AreEqual(
                "/services/data/" + TEST_API_VERSION + "/sobjects/" + TEST_OBJECT_TYPE + "/" + TEST_OBJECT_ID,
                request.Path, "Wrong path");
            Assert.IsNull(request.RequestBody, "Wrong request body");
            Assert.AreEqual(request.AdditionalHeaders.Count, 0);
        }
        public void TestDelete()
        {
            // Create
            IdName newAccountIdName = CreateAccount();

            // Delete
            RestResponse deleteResponse = _restClient.SendSync(RestRequest.GetRequestForDelete(TestCredentials.API_VERSION, "account", newAccountIdName.Id));

            Assert.IsTrue(deleteResponse.Success, "Delete failed");

            // Retrieve - expect 404
            RestResponse response = _restClient.SendSync(RestRequest.GetRequestForRetrieve(TestCredentials.API_VERSION, "account", newAccountIdName.Id, new string[] { "name" }));

            Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode, "404 was expected");
        }
示例#5
0
        public async Task TestDelete()
        {
            // Create
            IdName newAccountIdName = await CreateAccount();

            // Delete
            RestResponse deleteResponse =
                await
                _restClient.SendAsync(RestRequest.GetRequestForDelete(TestCredentials.API_VERSION, "account",
                                                                      newAccountIdName.Id));

            Assert.IsTrue(deleteResponse.Success, "Delete failed");

            // Retrieve - expect 404
            RestResponse response =
                await
                _restClient.SendAsync(RestRequest.GetRequestForRetrieve(TestCredentials.API_VERSION, "account",
                                                                        newAccountIdName.Id, new[] { "name" }));

            Assert.AreEqual(HttpStatusCode.NotFound.ToString().ToLower(), response.StatusCode.ToString().ToLower(), "404 was expected");
        }