public void TestCallWithBadAuthToken()
 {
     RestClient unauthenticatedRestClient = new RestClient(TestCredentials.INSTANCE_SERVER, BAD_TOKEN, null);
     RestResponse response = unauthenticatedRestClient.SendSync(RestRequest.GetRequestForResources(TestCredentials.API_VERSION));
     Assert.IsFalse(response.Success, "Success not expected");
     Assert.IsNotNull(response.Error, "Expected error");
     Assert.AreEqual(HttpStatusCode.Unauthorized, response.StatusCode, "Expected 401");
 }
        public void TestGetVersions()
        {
            // We don't need to be authenticated
            RestClient   unauthenticatedRestClient = new RestClient(TestCredentials.INSTANCE_SERVER, BAD_TOKEN, null);
            RestResponse response = unauthenticatedRestClient.SendSync(RestRequest.GetRequestForVersions());

            CheckResponse(response, HttpStatusCode.OK, true);
        }
        public void TestCallWithBadAuthToken()
        {
            RestClient   unauthenticatedRestClient = new RestClient(TestCredentials.INSTANCE_SERVER, BAD_TOKEN, null);
            RestResponse response = unauthenticatedRestClient.SendSync(RestRequest.GetRequestForResources(TestCredentials.API_VERSION));

            Assert.IsFalse(response.Success, "Success not expected");
            Assert.IsNotNull(response.Error, "Expected error");
            Assert.AreEqual(HttpStatusCode.Unauthorized, response.StatusCode, "Expected 401");
        }
        public void TestCallWithBadAuthTokenAndTokenProvider()
        {
            RestClient unauthenticatedRestClient = new RestClient(TestCredentials.INSTANCE_SERVER, BAD_TOKEN, () => Task.Factory.StartNew(() => _accessToken));

            Assert.AreEqual(BAD_TOKEN, unauthenticatedRestClient.AccessToken, "RestClient should be using the bad token initially");
            RestResponse response = unauthenticatedRestClient.SendSync(RestRequest.GetRequestForResources(TestCredentials.API_VERSION));

            Assert.IsTrue(response.Success, "Success expected");
            Assert.IsNull(response.Error, "Expected error");
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "Expected 200");
            Assert.AreEqual(_accessToken, unauthenticatedRestClient.AccessToken, "RestClient should now using the good token");
        }
 public void TestCallWithBadAuthTokenAndTokenProvider()
 {
     RestClient unauthenticatedRestClient = new RestClient(TestCredentials.INSTANCE_SERVER, BAD_TOKEN, () => Task.Factory.StartNew(() => _accessToken));
     Assert.AreEqual(BAD_TOKEN, unauthenticatedRestClient.AccessToken, "RestClient should be using the bad token initially");
     RestResponse response = unauthenticatedRestClient.SendSync(RestRequest.GetRequestForResources(TestCredentials.API_VERSION));
     Assert.IsTrue(response.Success, "Success expected");
     Assert.IsNull(response.Error, "Expected error");
     Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "Expected 200");
     Assert.AreEqual(_accessToken, unauthenticatedRestClient.AccessToken, "RestClient should now using the good token");
 }
 public void TestGetVersions()
 {
     // We don't need to be authenticated
     RestClient unauthenticatedRestClient = new RestClient(TestCredentials.INSTANCE_SERVER, BAD_TOKEN, null);
     RestResponse response = unauthenticatedRestClient.SendSync(RestRequest.GetRequestForVersions());
     CheckResponse(response, HttpStatusCode.OK, true);
 }
        public void TestGetResources()
        {
            RestResponse response = _restClient.SendSync(RestRequest.GetRequestForResources(TestCredentials.API_VERSION));

            CheckResponse(response, HttpStatusCode.OK, false);
            CheckKeys(response.AsJObject, "sobjects", "search", "recent");
        }