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\",\"sid\": \"BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"friendly_name\": \"update_name\",\"voice_url\": \"https://byoc.example.com/twilio_updated/app\",\"voice_method\": \"GET\",\"voice_fallback_method\": \"GET\",\"voice_fallback_url\": \"https://byoc.example.com/twilio_updated/fallback\",\"status_callback_method\": \"GET\",\"status_callback_url\": \"https://byoc.example.com/twilio_updated/status_callback\",\"cnam_lookup_enabled\": true,\"connection_policy_sid\": \"NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\",\"from_domain_sid\": \"SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\",\"date_created\": \"2020-03-18T23:31:36Z\",\"date_updated\": \"2020-03-18T23:31:37Z\",\"url\": \"https://voice.twilio.com/v1/ByocTrunks/BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}" )); var response = ByocTrunkResource.Update("BYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
public void TestUpdateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Voice, "/v1/ByocTrunks/BYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { ByocTrunkResource.Update("BYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }