public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"sid\": \"BN0044409f7e067e279523808d267e2d85\",\"account_sid\": \"AC78e8e67fc0246521490fb9907fd0c165\",\"customer_profile_bundle_sid\": \"BU3344409f7e067e279523808d267e2d85\",\"a2p_profile_bundle_sid\": \"BU3344409f7e067e279523808d267e2d85\",\"date_created\": \"2021-01-27T14:18:35Z\",\"date_updated\": \"2021-01-27T14:18:36Z\",\"status\": \"IN_PROGRESS\",\"tcr_id\": \"BXXXXXX\",\"failure_reason\": \"Registration error\",\"url\": \"https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85\"}" )); var response = BrandRegistrationResource.Fetch("BNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Get, Twilio.Rest.Domain.Messaging, "/v1/a2p/BrandRegistrations/BNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { BrandRegistrationResource.Fetch("BNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }