Example #1
0
        public void TestAuthorization()
        {
            var client = new Client(developerSid, authToken, apiUrl, apiVersion);

            string authString = Encoding.UTF8.GetString(Convert.FromBase64String(client.authString));

            string[] authParts = authString.Split(new char[] { ':' });

            Assert.AreEqual(authParts[0], developerSid);
            Assert.AreEqual(authParts[1], authToken);
        }
Example #2
0
        public void TestClientValidation()
        {
            Client cr;

            bool hasException = false;
            try
            {
                cr = new Client(string.Empty, string.Empty);
            }
            catch (ArgumentException) { hasException = true; }

            Assert.IsTrue(hasException);

            hasException = false;
            try
            {
                cr = new Client(developerSid, string.Empty);
            }
            catch (ArgumentException) { hasException = true; }

            Assert.IsTrue(hasException);

            hasException = false;
            try
            {
                cr = new Client(string.Empty, authToken);
            }
            catch (ArgumentException) { hasException = true; }

            Assert.IsTrue(hasException);

            hasException = false;

            hasException = false;

            cr = new Client(developerSid, authToken);
        }
Example #3
0
        public void test_get()
        {
            var client = new Client(developerSid, authToken, apiUrl, apiVersion);

            var response = client.Get("payments");
        }
Example #4
0
        public void test_different_url_and_version()
        {
            apiUrl = "https://www.reddit.com";
            apiVersion = "gold";

            var client = new Client(developerSid, authToken, apiUrl, apiVersion);

            Assert.AreEqual(apiUrl + "/" + apiVersion + "/", client.baseUrl);
        }
Example #5
0
 public void test_default_url_and_version()
 {
     var client = new Client(developerSid, authToken, apiUrl, apiVersion);
     Assert.AreEqual(client.baseUrl.Replace("-sandbox", string.Empty),
                  "https://api.poundpay.com/silver/");
 }
Example #6
0
        public void test_default_api_url_when_explicity_set_to_None()
        {
            apiUrl = null;

            var client = new Client(developerSid, authToken, apiUrl, apiVersion);

            Assert.IsFalse(String.IsNullOrEmpty(client.baseUrl));
        }
Example #7
0
        public void TestDeveloperSidValidation()
        {
            bool hasException = false;
            try
            {
                var cr = new Client("AB123123123", authToken);
            }
            catch (ArgumentException) { hasException = true; }

            Assert.IsTrue(hasException);
        }
Example #8
0
        public void TestDefaultApiVersionWhenExplicitlySetToNone()
        {
            apiVersion = null;

            var client = new Client(developerSid, authToken, apiUrl, apiVersion);

            Assert.IsTrue(client.baseUrl.EndsWith(Client.API_VERSION + "/"),
                client.baseUrl + " does not end with " + Client.API_VERSION + "/");
        }