Ejemplo n.º 1
0
        public void TestGetRequestForCreate()
        {
            RestRequest request = RestRequest.GetRequestForCreate(TEST_API_VERSION, TEST_OBJECT_TYPE, TEST_FIELDS);

            Assert.AreEqual(RestMethod.POST, request.Method, "Wrong method");
            Assert.AreEqual(ContentType.JSON, request.ContentType, "Wrong content type");
            Assert.AreEqual("/services/data/" + TEST_API_VERSION + "/sobjects/" + TEST_OBJECT_TYPE, request.Path, "Wrong path");
            Assert.AreEqual(TEST_FIELDS_string, request.Body, "Wrong request body");
            Assert.IsNull(request.AdditionalHeaders, "Wrong additional headers");
        }
Ejemplo n.º 2
0
        public void TestGetRequestForCreate()
        {
            RestRequest request = RestRequest.GetRequestForCreate(TEST_API_VERSION, TEST_OBJECT_TYPE, TEST_FIELDS);

            Assert.AreEqual(HttpMethod.Post, request.Method, "Wrong method");
            Assert.AreEqual(ContentTypeValues.Json, request.ContentType, "Wrong content type");
            Assert.AreEqual("/services/data/" + TEST_API_VERSION + "/sobjects/" + TEST_OBJECT_TYPE, request.Path,
                            "Wrong path");
            Assert.AreEqual(TEST_FIELDS_string, request.RequestBody, "Wrong request body");
            Assert.AreEqual(request.AdditionalHeaders.Count, 0);
        }
Ejemplo n.º 3
0
        public async Task TestCreateWithUnAuthenticatedClient()
        {
            var fields = new Dictionary <string, object> {
                { "name", generateAccountName() }
            };
            RestResponse response =
                await
                _unauthenticatedRestClient.SendAsync(RestRequest.GetRequestForCreate(TestCredentials.API_VERSION, "account", fields));

            Assert.AreEqual(response.StatusCode.ToString().ToLower(), HttpStatusCode.Unauthorized.ToString().ToLower());
        }
        private IdName CreateAccount()
        {
            string newAccountName = generateAccountName();
            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "name", newAccountName }
            };
            RestResponse response     = _restClient.SendSync(RestRequest.GetRequestForCreate(TestCredentials.API_VERSION, "account", fields));
            string       newAccountId = (string)response.AsJObject["id"];

            return(new IdName(newAccountId, newAccountName));
        }
        public void TestCreate()
        {
            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "name", generateAccountName() }
            };
            RestResponse response     = _restClient.SendSync(RestRequest.GetRequestForCreate(TestCredentials.API_VERSION, "account", fields));
            JObject      jsonResponse = response.AsJObject;

            CheckKeys(jsonResponse, "id", "errors", "success");
            Assert.IsTrue((bool)jsonResponse["success"], "Create failed");
        }
        private async Task <IdName> CreateAccount()
        {
            string newAccountName = generateAccountName();
            var    fields         = new Dictionary <string, object> {
                { "name", newAccountName }
            };
            var response =
                await
                _restClient.SendAsync(RestRequest.GetRequestForCreate(new TestCredentials().ApiVersion, "account", fields));

            var newAccountId = (string)response.AsJObject["id"];

            return(new IdName(newAccountId, newAccountName));
        }
        public async Task TestCreate()
        {
            var fields = new Dictionary <string, object> {
                { "name", generateAccountName() }
            };
            var response =
                await
                _restClient.SendAsync(RestRequest.GetRequestForCreate(new TestCredentials().ApiVersion, "account", fields));

            JObject jsonResponse = response.AsJObject;

            CheckKeys(jsonResponse, "id", "errors", "success");
            Assert.IsTrue((bool)jsonResponse["success"], "Create failed");
        }