public void GetApplicationListTest() { 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\":3,\"start\":0,\"end\":1,\"page\":0,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":\"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Applications&cursor=492dc883a811bd0204204ea9047122f93a2788a2\", \"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\"}, { \"uri\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Applications/AP6b60f3f88a46cc0ab42cb82781bdaa124a435076\", \"revision\" : 1, \"dateCreated\" : \"Mon, 30 Jan 2017 23:35:44 GMT\", \"dateUpdated\" : \"Mon, 30 Jan 2017 23:35:44 GMT\", \"applicationId\" : \"AP6b60f3f88a46cc0ab42cb82781bdaa124a435076\", \"accountId\" : \"AC66c1bebe590a6389f60efa0ee9ce74d44bc29747\", \"alias\" : \"test application 2\", \"voiceUrl\" : \"http://CreateAccountTest:3000/VoiceUrl\", \"callConnectUrl\" : \"http://CreateAccountTest:3000/CCUrl\", \"voiceFallbackUrl\" : \"http://CreateAccountTest:3000/VoiceUrl\", \"statusCallbackUrl\" : \"http://CreateAccountTest:3000/Status\"}]}"); ApplicationList appList = requester.get(); Assert.IsNotNull(appList); Assert.AreEqual(appList.getLocalSize, 2); Assert.AreEqual((appList.export()).Count, 2); Application app = appList.get(0) as Application; Assert.IsNotNull(app); Assert.AreEqual(app.getApplicationId, "APe4238465edbc017acfbddfe80c66594ef6c72669"); type = typeof(APIRequester); fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance); if (fieldInfo != null) { fieldInfo.SetValue(appList, "http://GetApplicationListTest:3000"); } TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK, "{\"total\":3,\"start\":2,\"end\":2,\"page\":1,\"numPages\":2,\"pageSize\":2,\"nextPageUri\":null, \"applications\" : [ { \"uri\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Applications/AP6b60f3f88a46cc0ab42cb82781bdaa124a435076\", \"revision\" : 1, \"dateCreated\" : \"Mon, 30 Jan 2017 23:35:44 GMT\", \"dateUpdated\" : \"Mon, 30 Jan 2017 23:35:44 GMT\", \"applicationId\" : \"AP6b60f3f88a46cc0ab42cb82781bdaa124a435076\", \"accountId\" : \"AC66c1bebe590a6389f60efa0ee9ce74d44bc29747\", \"alias\" : \"test application 2\", \"voiceUrl\" : \"http://CreateAccountTest:3000/VoiceUrl\", \"callConnectUrl\" : \"http://CreateAccountTest:3000/CCUrl\", \"voiceFallbackUrl\" : \"http://CreateAccountTest:3000/VoiceUrl\", \"statusCallbackUrl\" : \"http://CreateAccountTest:3000/Status\"}]}"); appList.loadNextPage(); Assert.IsNotNull(appList); Assert.AreEqual(appList.getLocalSize, 3); Assert.AreEqual((appList.export()).Count, 3); app = appList.get(2) as Application; Assert.IsNotNull(app); Assert.AreEqual(app.getApplicationId, "AP6b60f3f88a46cc0ab42cb82781bdaa124a435076"); } catch (PersyException pe) { Assert.Fail(pe.Message); } }