public void GetApplicationListByAliasTest() { try { ApplicationsRequester requester = new ApplicationsRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(requester, "http://GetApplicationListTest:3000"); } WebRequest.RegisterPrefix("http://GetApplicationListTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":1,\"start\":0,\"end\":0,\"page\":0,\"numPages\":1,\"pageSize\":2,\"nextPageUri\":null, \"applications\" : [{ \"uri\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Applications/APe4238465edbc017acfbddfe80c66594ef6c72669\", \"revision\" : 2, \"dateCreated\" : \"Mon, 30 Jan 2017 23:35:00 GMT\", \"dateUpdated\" : \"Mon, 30 Jan 2017 23:44:39 GMT\", \"applicationId\" : \"APe4238465edbc017acfbddfe80c66594ef6c72669\", \"accountId\" : \"AC66c1bebe590a6389f60efa0ee9ce74d44bc29747\", \"alias\" : \"new test application 1\", \"voiceUrl\" : \"http://CreateAccountTest:3000/VoiceUrl2\", \"callConnectUrl\" : \"http://CreateAccountTest:3000/CCUrl2\", \"voiceFallbackUrl\" : \"http://CreateAccountTest:3000/VoiceUrl2\", \"statusCallbackUrl\" : \"http://CreateAccountTest:3000/Status2\"}]}"); ApplicationsSearchFilters filters = new ApplicationsSearchFilters(); filters.setAlias("new test application 1"); ApplicationList appList = requester.get(filters); Assert.IsNotNull(appList); Assert.AreEqual(appList.getLocalSize, 1); Assert.AreEqual((appList.export()).Count, 1); Application app = appList.get(0) as Application; Assert.IsNotNull(app); Assert.AreEqual(app.getApplicationId, "APe4238465edbc017acfbddfe80c66594ef6c72669"); Assert.AreEqual(app.getAlias, "new test application 1"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }
public void MakeAInitialConferenceRequestWithRequestIdTest() { try { ConferencesRequester confRequester = new ConferencesRequester("AC736ca2078721a9a41fb47f07bf40d9e21cb304da", "8e3d1c1c519fc761856f8cc825bcfea94d8c58b5", "AC736ca2078721a9a41fb47f07bf40d9e21cb304da"); Type confRequesterType = typeof(ConferencesRequester); MethodInfo freeClimbUrlMethodInfo = confRequesterType.GetMethod("SetFreeClimbUrl", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(System.String) }, null); freeClimbUrlMethodInfo.Invoke(confRequester, new Object[] { "http://MakeAInitialConferenceRequestTest:3000" }); WebRequest.RegisterPrefix("http://MakeAInitialConferenceRequestTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"uri\" : \"/Accounts/AC142c48f2ee663e214c19ea459516068c/Conferences/CFbbe46ff1274e283f7e3ac1df0072ab39\", \"revision\" : 1, \"dateCreated\" : \"Thu, 23 Jun 2016 17:30:06 GMT\", \"dateUpdated\" : \"Thu, 23 Jun 2016 17:30:06 GMT\", \"conferenceId\" : \"CFbbe46ff1274e283f7e3ac1df0072ab39\", \"accountId\" : \"AC142c48f2ee663e214c19ea459516068c\", \"alias\" : \"API\", \"status\" : \"empty\", \"subresourceUris\" : { \"participants\" : \"/Accounts/AC142c48f2ee663e214c19ea459516068c/Conferences/CFbbe46ff1274e283f7e3ac1df0072ab39/Participants\", \"recordings\" : \"/Accounts/AC142c48f2ee663e214c19ea459516068c/Conferences/CFbbe46ff1274e283f7e3ac1df0072ab39/Recordings\"}}"); ConferenceCreateOptions options = new ConferenceCreateOptions(); options.setAlias("API"); options.setRequestId("RQ1234567890123456789012345678901234567890"); Conference conference = confRequester.create(options); Assert.IsNotNull(conference); Assert.AreEqual(conference.getUri, "/Accounts/AC142c48f2ee663e214c19ea459516068c/Conferences/CFbbe46ff1274e283f7e3ac1df0072ab39"); Assert.AreEqual(conference.getSubresourceUris.Count, 2); Assert.AreEqual(conference.getRevision, 1); Assert.IsNotNull(conference.getDateCreated); Assert.IsNotNull(conference.getDateUpdated); Assert.AreEqual(conference.getStatus, EConferenceStatus.Empty); } catch (FreeClimbException pe) { Assert.Fail(pe.Message); } }
public void MakeUpdateRequestTest() { try { CallsRequester callsRequester = new CallsRequester("AC736ca2078721a9a41fb47f07bf40d9e21cb304da", "8e3d1c1c519fc761856f8cc825bcfea94d8c58b5", "AC736ca2078721a9a41fb47f07bf40d9e21cb304da"); Type callsRequesterType = typeof(CallsRequester); MethodInfo persyUrlMethodInfo = callsRequesterType.GetMethod("setPersyUrl", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(System.String) }, null); persyUrlMethodInfo.Invoke(callsRequester, new Object[] { "http://MakeUpdateRequestTest:3000" }); WebRequest.RegisterPrefix("http://MakeUpdateRequestTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"uri\" : \"/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Calls/CA16ac1bcbd6f4895c89a798571e89e1e715892924\", \"revision\" : 1, \"dateCreated\" : \"Thu, 23 Jun 2016 17:30:06 GMT\", \"dateUpdated\" : \"Thu, 23 Jun 2016 17:30:06 GMT\", \"callId\" : \"CA16ac1bcbd6f4895c89a798571e89e1e715892924\", \"parentCallId\" : null, \"accountId\" : \"AC736ca2078721a9a41fb47f07bf40d9e21cb304da\", \"from\" : \"+12248806205\", \"to\" : \"+18475978014\", \"phoneNumberId\" : \"PN1311218371073288ff9c0434698753f98ea4228a\", \"status\" : \"canceled\", \"startTime\" : null, \"endTime\" : null, \"duration\" : 0, \"direction\" : \"outboundAPI\", \"answeredBy\" : null, \"callerName\" : null, \"subresourceUris\" : {\"notifications\" : \"/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Calls/CA16ac1bcbd6f4895c89a798571e89e1e715892924/Notifications\", \"recordings\" : \"/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Calls/CA16ac1bcbd6f4895c89a798571e89e1e715892924/Recordings\"}}"); CallTermOptions callOptions = new CallTermOptions(); callOptions.setStatus(ECallStatus.Canceled); Call call = callsRequester.update("CA16ac1bcbd6f4895c89a798571e89e1e715892924", callOptions); Assert.IsNotNull(call); Assert.IsNotNull(call.getUri); Assert.AreEqual(call.getUri, "/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Calls/CA16ac1bcbd6f4895c89a798571e89e1e715892924"); Assert.AreEqual(call.getSubresourceUris.Count, 2); Assert.AreEqual(call.getRevision, 1); Assert.IsNotNull(call.getDateCreated); Assert.IsNotNull(call.getDateUpdated); Assert.AreEqual(call.getStatus, ECallStatus.Canceled); } catch (PersyException pe) { Assert.Fail(pe.Message); } }
public void GetRecordingListByCallIdTest() { try { RecordingsRequester recordingsRequester = new RecordingsRequester("AC736ca2078721a9a41fb47f07bf40d9e21cb304da", "8e3d1c1c519fc761856f8cc825bcfea94d8c58b5", "AC736ca2078721a9a41fb47f07bf40d9e21cb304da"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(recordingsRequester, "http://GetRecordingListTest:3000"); } WebRequest.RegisterPrefix("http://GetRecordingListTest:3000/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Recordings?callId=CF3cb8a52f461bcf64cbd3111d9492c3f61943eef9", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":1,\"start\":0,\"end\":0,\"page\":1,\"numPages\":1,\"pageSize\":20,\"nextPageUri\":null,\"recordings\":[{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Recordings/REb1eecfce410141ad1749c0fc84dfbb6fc4c2a815\",\"revision\":1,\"dateCreated\":\"Mon, 27 Jun 2016 17:53:55 GMT\",\"dateUpdated\":\"Mon, 27 Jun 2016 17:53:55 GMT\",\"recordingId\":\"REb1eecfce410141ad1749c0fc84dfbb6fc4c2a815\",\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"callId\":\"CF3cb8a52f461bcf64cbd3111d9492c3f61943eef9\",\"duration\":9}]}"); RecordingsSearchFilters filters = new RecordingsSearchFilters(); filters.setCallId("CF3cb8a52f461bcf64cbd3111d9492c3f61943eef9"); RecordingList recordingList = recordingsRequester.getMeta(filters); Assert.IsNotNull(recordingList); Assert.AreEqual(recordingList.getLocalSize, 1); Assert.AreEqual((recordingList.export()).Count, 1); Recording recording = recordingList.get(0) as Recording; Assert.IsNotNull(recording); Assert.AreEqual(recording.getRecordingId, "REb1eecfce410141ad1749c0fc84dfbb6fc4c2a815"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }
public void GetLogListUsingPqlTest() { try { LogsRequester requester = new LogsRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(requester, "http://GetLogListTest:3000"); } WebRequest.RegisterPrefix("http://GetLogListTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":1,\"start\":0,\"end\":0,\"page\":0,\"numPages\":1,\"pageSize\":2,\"nextPageUri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Applications&cursor=492dc883a811bd0204204ea9047122f93a2788a2\", \"logs\" : [{\"hostname\":\"spv07vcs10\",\"subsystem\":\"vcsserver\",\"timestamp\":1485450178603416,\"scope\":\"public\",\"level\":\"info\",\"accountId\":\"AC907d7e328b3a5b402fa908857e047a243a8949b1\",\"requestId\":null,\"callId\":\"CA5c8c6d7df5d19096eb71ce516a39ade6aa1b0d4f\",\"message\":\"Customer Response 200 : POST http://172.29.11.10/FreeClimbSurvey/FreeClimbSurvey/NextQuestion\",\"metadata\":[{\"GetSpeech\":{\"actionUrl\":\"http://172.29.11.10/FreeClimbSurvey/FreeClimbSurvey/HandleQuestionResponse\",\"grammarFile\":\"http://172.29.11.10/FreeClimbSurvey/Grammars/969d88d2-8edb-4ad9-8436-aa0c4d268f56.grxml\",\"grammarRule\":\"Choices\",\"grammarType\":\"URL\",\"noInputTimeoutMs\":4000,\"prompts\":[{\"Say\":{\"text\":\"what is your favorite color\"}}],\"recognitionTimeoutMs\":5000}}]}]}"); LogSearchFilters filters = new LogSearchFilters(); string pql = "level=\"info\""; filters.setPql(pql); LogList logList = requester.get(filters); Assert.IsNotNull(logList); Assert.AreEqual(logList.getLocalSize, 1); Assert.AreEqual((logList.export()).Count, 1); Log log = logList.get(0) as Log; Assert.IsNotNull(log); Assert.AreEqual(log.getLevel, ELogLevel.Info); } catch (FreeClimbException pe) { Assert.Fail(pe.Message); } }
public void DeleteApplicationTest() { try { ApplicationsRequester requester = new ApplicationsRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(requester, "http://DeleteApplicationTest:3000"); } WebRequest.RegisterPrefix("http://DeleteApplicationTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK); requester.delete("APe4238465edbc017acfbddfe80c66594ef6c72669"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }
public void DeleteIncomingNumberTest() { try { IncomingPhoneNumbersRequester requester = new IncomingPhoneNumbersRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(requester, "http://DeleteIncomingTest:3000"); } WebRequest.RegisterPrefix("http://DeleteIncomingTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK); requester.delete("PN3816047eda7b012ea2cf6d5e0697a2474363dcd6"); } catch (FreeClimbException pe) { Assert.Fail(pe.Message); } }
public void DeleteCallingNumberTest() { try { CallingNumbersRequester requester = new CallingNumbersRequester("AC907d7e328b3a5b402fa908857e047a243a8949b1", "2c78e8a8d1033b77902758e584ad5fc4a1c5ee02", "AC907d7e328b3a5b402fa908857e047a243a8949b1"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(requester, "http://DeleteCallingTest:3000"); } WebRequest.RegisterPrefix("http://DeleteCallingTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK); requester.delete("PN7bbef986a434fd30ba006551ed6cc507403b5e87"); } catch (FreeClimbException pe) { Assert.Fail(pe.Message); } }
public void QueueMemberTest() { QueuesRequester queuesRequester = new QueuesRequester("AC736ca2078721a9a41fb47f07bf40d9e21cb304da", "8e3d1c1c519fc761856f8cc825bcfea94d8c58b5", "AC736ca2078721a9a41fb47f07bf40d9e21cb304da"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(queuesRequester, "http://QueueMember:3000"); } WebRequest.RegisterPrefix("http://QueueMember:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"callId\": \"CA386025c9bf5d6052a1d1ea42b4d16662\", \"dateEnqueued\": \"Thu, 23 Jun 2016 17:30:06 GMT\",\"waitTime\": 30,\"position\": 1, \"uri\": \"/Accounts/AC142c48f2ee663e214c19ea459516068c/Queues/QU5ef8732a3c49700934481addd5ce1659/Members/CA386025c9bf5d6052a1d1ea42b4d16662\"}"); QueueMember queueMember = queuesRequester.getQueueMember("QU5ef8732a3c49700934481addd5ce1659", "CA386025c9bf5d6052a1d1ea42b4d16662"); Assert.IsNotNull(queueMember); Assert.IsNotNull(queueMember.getUri); Assert.AreEqual(queueMember.getUri, "/Accounts/AC142c48f2ee663e214c19ea459516068c/Queues/QU5ef8732a3c49700934481addd5ce1659/Members/CA386025c9bf5d6052a1d1ea42b4d16662"); Assert.IsNotNull(queueMember.getCallId); Assert.AreEqual(queueMember.getCallId, "CA386025c9bf5d6052a1d1ea42b4d16662"); }
public void DeleteAccountTest() { try { AccountsRequester accountRequester = new AccountsRequester("ACabe7063197551fe51671f9ac3a9708e9dad51c4d", "204c15aae7a486c42776aea4dbafe8c68a773071"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(accountRequester, "http://DeleteAccountTest:3000"); } WebRequest.RegisterPrefix("http://DeleteAccountTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK); accountRequester.delete("AC66c1bebe590a6389f60efa0ee9ce74d44bc29747"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }
public void DeleteRecordingTest() { try { RecordingsRequester recordingsRequester = new RecordingsRequester("ACabe7063197551fe51671f9ac3a9708e9dad51c4d", "204c15aae7a486c42776aea4dbafe8c68a773071", "ACabe7063197551fe51671f9ac3a9708e9dad51c4d"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(recordingsRequester, "http://DeleteRecordingTest:3000"); } WebRequest.RegisterPrefix("http://DeleteRecordingTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK); recordingsRequester.delete("REb1eecfce410141ad1749c0fc84dfbb6fc4c2a810"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }
public static void InitializeClass(TestContext context) { log = LogManager.GetLogger(typeof(HttpRequestFactoryTest)); TestWebRequestCreate.SetupResponsePath("Responses/"); }
public void GetCallListWithStartTimeAndToQueryTest() { try { CallsRequester callsRequester = new CallsRequester("AC736ca2078721a9a41fb47f07bf40d9e21cb304da", "8e3d1c1c519fc761856f8cc825bcfea94d8c58b5", "AC736ca2078721a9a41fb47f07bf40d9e21cb304da"); Type callsRequesterType = typeof(CallsRequester); MethodInfo persyUrlMethodInfo = callsRequesterType.GetMethod("setPersyUrl", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(System.String) }, null); persyUrlMethodInfo.Invoke(callsRequester, new Object[] { "http://GetCallListWithStartTimeAndToQueryTest:3000" }); WebRequest.RegisterPrefix("http://GetCallListWithStartTimeAndToQueryTest:3000/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Calls?to=%2b1234567890&startTime=2015-01-01%2000%3a00%3a00", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":3,\"start\":0,\"end\":1,\"page\":0,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls?cursor=492dc883a811bd0204204ea9047122f93a2788a2\",\"calls\":[{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd883b\",\"revision\":1,\"dateCreated\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"dateUpdated\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"callId\":\"CAfe92a5efbaf90f04bbec946a0d74dad520dd883b\",\"parentCallId\":null,\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"from\":\"847655770\",\"to\":\"+11112223333\",\"phoneNumberId\":null,\"status\":\"completed\",\"startTime\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"endTime\":\"Mon, 28 Mar 2016 19:58:30 GMT\",\"duration\":9,\"direction\":\"inbound\",\"answeredBy\":null,\"callerName\":null,\"subresourceUris\":{\"notifications\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd883b/Notifications\",\"recordings\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd883b/Recordings\"}},{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CA25c3c744acdedcdb92a44dbae42d486bf20028ab\",\"revision\":1,\"dateCreated\":\"Mon, 28 Mar 2016 20:03:42 GMT\",\"dateUpdated\":\"Mon, 28 Mar 2016 20:03:42 GMT\",\"callId\":\"CA25c3c744acdedcdb92a44dbae42d486bf20028ab\",\"parentCallId\":null,\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"from\":\"847655770\",\"to\":\"+11112223333\",\"phoneNumberId\":null,\"status\":\"completed\",\"startTime\":\"Mon, 28 Mar 2016 20:03:42 GMT\",\"endTime\":\"Mon, 28 Mar 2016 20:03:50 GMT\",\"duration\":8,\"direction\":\"inbound\",\"answeredBy\":null,\"callerName\":null,\"subresourceUris\":{\"notifications\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CA25c3c744acdedcdb92a44dbae42d486bf20028ab/Notifications\",\"recordings\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CA25c3c744acdedcdb92a44dbae42d486bf20028ab/Recordings\"}}]}"); CallsSearchFilters listOptions = new CallsSearchFilters(); listOptions.setStartTime("2015-01-01 00:00:00"); listOptions.setTo("+1234567890"); CallList callList = callsRequester.get(listOptions); Assert.IsNotNull(callList); Assert.AreEqual(callList.getLocalSize, 2); Assert.AreEqual((callList.export()).Count, 2); Call call = callList.get(0) as Call; Assert.IsNotNull(call); Assert.AreEqual(call.getCallId, "CAfe92a5efbaf90f04bbec946a0d74dad520dd883b"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(callList, "http://GetCallListWithStartTimeAndToQueryTest:3000"); } WebRequest.RegisterPrefix("http://GetCallListWithStartTimeAndToQueryTest:3000/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls?cursor=492dc883a811bd0204204ea9047122f93a2788a2", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":3,\"start\":2,\"end\":2,\"page\":1,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":null,\"calls\":[{\"uri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd884b\",\"revision\":1,\"dateCreated\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"dateUpdated\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"callId\":\"CAfe92a5efbaf90f04bbec946a0d74dad520dd884b\",\"parentCallId\":null,\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"from\":\"847655770\",\"to\":\"+11112223333\",\"phoneNumberId\":null,\"status\":\"completed\",\"startTime\":\"Mon, 28 Mar 2016 19:58:21 GMT\",\"endTime\":\"Mon, 28 Mar 2016 19:58:30 GMT\",\"duration\":9,\"direction\":\"inbound\",\"answeredBy\":null,\"callerName\":null,\"subresourceUris\":{\"notifications\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd883b/Notifications\",\"recordings\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Calls/CAfe92a5efbaf90f04bbec946a0d74dad520dd883b/Recordings\"}}]}"); callList.loadNextPage(); Assert.IsNotNull(callList); Assert.AreEqual(callList.getLocalSize, 3); Assert.AreEqual((callList.export()).Count, 3); call = callList.get(2) as Call; Assert.IsNotNull(call); Assert.AreEqual(call.getCallId, "CAfe92a5efbaf90f04bbec946a0d74dad520dd884b"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }
public void GetMessageListTest() { try { MessagesRequester requester = new MessagesRequester("AC736ca2078721a9a41fb47f07bf40d9e21cb304da", "8e3d1c1c519fc761856f8cc825bcfea94d8c58b5", "AC736ca2078721a9a41fb47f07bf40d9e21cb304da"); Type type = typeof(APIRequester); FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(requester, "http://GetMessageListTest:3000"); } string to = "+18475978014"; string from = "+12248806205"; string text = "Hello World"; WebRequest.RegisterPrefix("http://GetMessageListTest:3000", new TestWebRequestCreate()); TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":3,\"start\":0,\"end\":1,\"page\":0,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":\"/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Messages&cursor=492dc883a811bd0204204ea9047122f93a2788a2\", \"messages\" : [{\"uri\" : \"/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Messages/MM16ac1bcbd6f4895c89a798571e89e1e715892924\", \"revision\" : 1, \"dateCreated\" : \"Thu, 23 Jun 2016 17:30:06 GMT\", \"dateUpdated\" : \"Thu, 23 Jun 2016 17:30:06 GMT\", \"messageId\" : \"MM16ac1bcbd6f4895c89a798571e89e1e715892924\", \"accountId\" : \"AC736ca2078721a9a41fb47f07bf40d9e21cb304da\", \"from\" : \"" + from + "\", \"to\" : \"" + to + "\", \"text\" : \"" + text + "\", \"direction\" : \"inbound\", \"status\" : \"received\"}, {\"uri\" : \"/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Messages/MM16ac1bcbd6f4895c89a798571e89e1e715892925\", \"revision\" : 1, \"dateCreated\" : \"Thu, 23 Jun 2016 17:30:06 GMT\", \"dateUpdated\" : \"Thu, 23 Jun 2016 17:30:06 GMT\", \"messageId\" : \"MM16ac1bcbd6f4895c89a798571e89e1e715892925\", \"accountId\" : \"AC736ca2078721a9a41fb47f07bf40d9e21cb304da\", \"from\" : \"" + from + "\", \"to\" : \"" + to + "\", \"text\" : \"" + text + "\", \"direction\" : \"inbound\", \"status\" : \"received\"}]}"); MessageList msgList = requester.get(); Assert.IsNotNull(msgList); Assert.AreEqual(msgList.getLocalSize, 2); Assert.AreEqual((msgList.export()).Count, 2); Message msg = msgList.get(0) as Message; Assert.IsNotNull(msg); Assert.AreEqual(msg.getMessageId, "MM16ac1bcbd6f4895c89a798571e89e1e715892924"); type = typeof(APIRequester); fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(msgList, "http://GetMessageListTest:3000"); } TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":3,\"start\":2,\"end\":2,\"page\":1,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":null, \"messages\" : [{\"uri\" : \"/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Messages/MM16ac1bcbd6f4895c89a798571e89e1e715892926\", \"revision\" : 1, \"dateCreated\" : \"Thu, 23 Jun 2016 17:30:06 GMT\", \"dateUpdated\" : \"Thu, 23 Jun 2016 17:30:06 GMT\", \"messageId\" : \"MM16ac1bcbd6f4895c89a798571e89e1e715892926\", \"accountId\" : \"AC736ca2078721a9a41fb47f07bf40d9e21cb304da\", \"from\" : \"" + from + "\", \"to\" : \"" + to + "\", \"text\" : \"" + text + "\", \"direction\" : \"inbound\", \"status\" : \"received\"}]}"); msgList.loadNextPage(); Assert.IsNotNull(msgList); Assert.AreEqual(msgList.getLocalSize, 3); Assert.AreEqual((msgList.export()).Count, 3); msg = msgList.get(2) as Message; Assert.IsNotNull(msg); Assert.AreEqual(msg.getMessageId, "MM16ac1bcbd6f4895c89a798571e89e1e715892926"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }
public static void InitializeClass(TestContext context) { log = LogManager.GetLogger(typeof(ProductCampaignTest)); TestWebRequestCreate.SetupResponsePath("Responses/"); }
public void TestWebRequest(HttpStatusCode code, int result) { int total = 0; Assert.ThrowsAsync <WebException>(async() => await instance.WebPolicy.ExecuteAsync( () => { total++; throw new WebException("Test", new Exception(), WebExceptionStatus.Success, TestWebRequestCreate.CreateTestWebResponse("ss", code)); }) .ConfigureAwait(false)); Assert.AreEqual(result, total); }