Exemple #1
0
        public void TestReadFullResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"meta\": {\"previous_page_url\": null,\"url\": \"https://bulkexports.twilio.com/v1/Exports/Messages/Jobs?PageSize=50&Page=0\",\"page_size\": 50,\"key\": \"jobs\",\"first_page_url\": \"https://bulkexports.twilio.com/v1/Exports/Messages/Jobs?PageSize=50&Page=0\",\"next_page_url\": null,\"page\": 0},\"jobs\": [{\"start_day\": \"start_day\",\"job_sid\": \"JSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"friendly_name\": \"friendly_name\",\"webhook_method\": \"webhook_method\",\"details\": {},\"end_day\": \"end_day\",\"webhook_url\": \"webhook_url\",\"email\": \"email\",\"resource_type\": \"resource_type\"}]}"
                         ));

            var response = ExportCustomJobResource.Read("resource_type", client: twilioRestClient);

            Assert.NotNull(response);
        }
Exemple #2
0
        public void TestReadEmptyResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"meta\": {\"previous_page_url\": null,\"url\": \"https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0\",\"page_size\": 50,\"key\": \"jobs\",\"first_page_url\": \"https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0\",\"next_page_url\": null,\"page\": 0},\"jobs\": []}"
                         ));

            var response = ExportCustomJobResource.Read("resource_type", client: twilioRestClient);

            Assert.NotNull(response);
        }
Exemple #3
0
        public void TestReadRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Get,
                Twilio.Rest.Domain.Bulkexports,
                "/v1/Exports/resource_type/Jobs",
                ""
                );

            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                ExportCustomJobResource.Read("resource_type", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }