Ejemplo n.º 1
0
        public void TestFetchResultsWithEtagResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"update_time\": \"2020-05-19T19:47:51Z\",\"file_link\": \"https://www.twilio.com\",\"file_link_ttl_in_seconds\": \"900\",\"url\": \"https://preview.twilio.com/TrustedComms/BrandsInformation\"}"
                         ));

            var response = BrandsInformationResource.Fetch(client: twilioRestClient);

            Assert.NotNull(response);
        }
Ejemplo n.º 2
0
        public void TestFetchRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Get,
                Twilio.Rest.Domain.Preview,
                "/TrustedComms/BrandsInformation",
                ""
                );

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

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