コード例 #1
0
        public void CreateApplicationWithRequestIdTest()
        {
            try
            {
                ApplicationsRequester requester = new ApplicationsRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1");

                Type      type      = typeof(APIRequester);
                FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance);
                if (fieldInfo != null)
                {
                    fieldInfo.SetValue(requester, "http://CreateApplicationTest:3000");
                }

                WebRequest.RegisterPrefix("http://CreateApplicationTest:3000", new TestWebRequestCreate());

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"uri\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Applications/APe4238465edbc017acfbddfe80c66594ef6c72669\", \"revision\" : 1, \"dateCreated\" : \"Mon, 30 Jan 2017 23:35:00 GMT\", \"dateUpdated\" : \"Mon, 30 Jan 2017 23:35:00 GMT\", \"applicationId\" : \"APe4238465edbc017acfbddfe80c66594ef6c72669\", \"accountId\" : \"AC66c1bebe590a6389f60efa0ee9ce74d44bc29747\", \"alias\" : \"test application 1\", \"voiceUrl\" : \"http://CreateApplicationTest:3000/VoiceUrl\", \"callConnectUrl\" : \"http://CreateApplicationTest:3000/CCUrl\", \"voiceFallbackUrl\" : \"http://CreateApplicationTest:3000/VoiceUrl\", \"statusCallbackUrl\" : \"http://CreateApplicationTest:3000/Status\",  \"smsUrl\" : \"http://CreateApplicationTest:3000/SmsUrl\", \"smsFallbackUrl\" : \"http://CreateApplicationTest:3000/SmsUrl2\"}");
                ApplicationOptions options = new ApplicationOptions();
                options.setAlias("test application 1");
                options.setVoiceUrl("http://CreateApplicationTest:3000/VoiceUrl");
                options.setVoiceFallbackUrl("http://CreateApplicationTest:3000/VoiceUrl");
                options.setSmsUrl("http://CreateApplicationTest:3000/SmsUrl");
                options.setSmsFallbackUrl("http://CreateApplicationTest:3000/SmsUrl2");
                options.setCallConnectUrl("http://CreateApplicationTest:3000/CCUrl");
                options.setStatusCallbackUrl("http://CreateApplicationTest:3000/Status");
                options.setRequestId("RQ1234567890123456789012345678901234567890");
                Application app = requester.create(options);

                Assert.IsNotNull(app);
                Assert.AreEqual(app.getAlias, "test application 1");
                Assert.AreEqual(app.getVoiceFallbackUrl, "http://CreateApplicationTest:3000/VoiceUrl");
                Assert.AreEqual(app.getVoiceUrl, "http://CreateApplicationTest:3000/VoiceUrl");
                Assert.AreEqual(app.getSmsFallbackUrl, "http://CreateApplicationTest:3000/SmsUrl2");
                Assert.AreEqual(app.getSmsUrl, "http://CreateApplicationTest:3000/SmsUrl");
                Assert.AreEqual(app.getStatusCallbackUrl, "http://CreateApplicationTest:3000/Status");
                Assert.AreEqual(app.getCallConnectUrl, "http://CreateApplicationTest:3000/CCUrl");
                Assert.AreEqual(app.getAccountId, "AC66c1bebe590a6389f60efa0ee9ce74d44bc29747");
                Assert.AreEqual(app.getApplicationId, "APe4238465edbc017acfbddfe80c66594ef6c72669");
            }
            catch (FreeClimbException pe)
            {
                Assert.Fail(pe.Message);
            }
        }