public async Task TestUpdate() { // Create IdName newAccountIdName = await CreateAccount(); // Update string updatedAccountName = generateAccountName(); var fields = new Dictionary <string, object> { { "name", updatedAccountName } }; RestResponse updateResponse = await _restClient.SendAsync(RestRequest.GetRequestForUpdate(TestCredentials.API_VERSION, "account", newAccountIdName.Id, fields)); Assert.IsTrue(updateResponse.Success, "Update failed"); // Retrieve - expect updated name RestResponse response = await _restClient.SendAsync(RestRequest.GetRequestForRetrieve(TestCredentials.API_VERSION, "account", newAccountIdName.Id, new[] { "name" })); Assert.AreEqual(updatedAccountName, response.AsJObject["Name"], "Wrong row returned"); }
public void TestGetRequestForRetrieve() { RestRequest request = RestRequest.GetRequestForRetrieve(TEST_API_VERSION, TEST_OBJECT_TYPE, TEST_OBJECT_ID, TEST_FIELDS_LIST); Assert.AreEqual(RestMethod.GET, 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 + "?fields=" + TEST_FIELDS_LIST_string, request.Path, "Wrong path"); Assert.IsNull(request.Body, "Wrong request body"); Assert.IsNull(request.AdditionalHeaders, "Wrong additional headers"); }
public void TestRetrieve() { string[] fields = new string[] { "name", "ownerId" }; IdName newAccountIdName = CreateAccount(); RestResponse response = _restClient.SendSync(RestRequest.GetRequestForRetrieve(TestCredentials.API_VERSION, "account", newAccountIdName.Id, fields)); CheckResponse(response, HttpStatusCode.OK, false); JObject jsonResponse = response.AsJObject; CheckKeys(jsonResponse, "attributes", "Name", "OwnerId", "Id"); Assert.AreEqual(newAccountIdName.Name, jsonResponse["Name"], "Wrong row returned"); }
public async Task TestRetrieveWithUnAuthenticatedClient() { string[] fields = { "name", "ownerId" }; IdName newAccountIdName = await CreateAccount(); RestResponse response = await _unauthenticatedRestClient.SendAsync(RestRequest.GetRequestForRetrieve(TestCredentials.API_VERSION, "account", newAccountIdName.Id, fields)); Assert.AreEqual(response.StatusCode.ToString().ToLower(), HttpStatusCode.Unauthorized.ToString().ToLower()); }
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"); }
public async Task TestRetrieve() { string[] fields = { "name", "ownerId" }; IdName newAccountIdName = await CreateAccount(); var response = await _restClient.SendAsync(RestRequest.GetRequestForRetrieve(new TestCredentials().ApiVersion, "account", newAccountIdName.Id, fields)); CheckResponse(response, HttpStatusCode.OK, false); JObject jsonResponse = response.AsJObject; CheckKeys(jsonResponse, "attributes", "Name", "OwnerId", "Id"); Assert.AreEqual(newAccountIdName.Name, jsonResponse["Name"], "Wrong row returned"); }
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"); }