Пример #1
0
        public void TestUpdateResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"type\": \"com.twilio.voice.call.initiated\",\"version\": 6,\"subscription_sid\": \"DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"url\": \"https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.voice.call.initiated\"}"
                         ));

            var response = SubscribedEventResource.Update("DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "type", 1, client: twilioRestClient);

            Assert.NotNull(response);
        }
Пример #2
0
        public void TestUpdateRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Post,
                Twilio.Rest.Domain.Events,
                "/v1/Subscriptions/DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribedEvents/type",
                ""
                );

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

            try
            {
                SubscribedEventResource.Update("DFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "type", 1, client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }