Esempio n. 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\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://voice.twilio.com/v1/SourceIpMappings?PageSize=50&Page=0\",\"previous_page_url\": null,\"url\": \"https://voice.twilio.com/v1/SourceIpMappings?PageSize=50&Page=0\",\"next_page_url\": null,\"key\": \"source_ip_mappings\"},\"source_ip_mappings\": [{\"sid\": \"IBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"ip_record_sid\": \"ILaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"sip_domain_sid\": \"SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": \"2020-03-18T23:31:36Z\",\"date_updated\": \"2020-03-18T23:31:37Z\",\"url\": \"https://voice.twilio.com/v1/SourceIpMappings/IBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}]}"
                         ));

            var response = SourceIpMappingResource.Read(client: twilioRestClient);

            Assert.NotNull(response);
        }
Esempio n. 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\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://voice.twilio.com/v1/SourceIpMappings?PageSize=50&Page=0\",\"previous_page_url\": null,\"url\": \"https://voice.twilio.com/v1/SourceIpMappings?PageSize=50&Page=0\",\"next_page_url\": null,\"key\": \"source_ip_mappings\"},\"source_ip_mappings\": []}"
                         ));

            var response = SourceIpMappingResource.Read(client: twilioRestClient);

            Assert.NotNull(response);
        }
Esempio n. 3
0
        public void TestReadRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Get,
                Twilio.Rest.Domain.Voice,
                "/v1/SourceIpMappings",
                ""
                );

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

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