示例#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);
        }
示例#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);
        }
示例#3
0
        public void test_get()
        {
            var client = new Client(developerSid, authToken, apiUrl, apiVersion);

            var response = client.Get("payments");
        }
示例#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);
        }
示例#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/");
 }
示例#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));
        }
示例#7
0
        public void TestDeveloperSidValidation()
        {
            bool hasException = false;
            try
            {
                var cr = new Client("AB123123123", authToken);
            }
            catch (ArgumentException) { hasException = true; }

            Assert.IsTrue(hasException);
        }
示例#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 + "/");
        }