public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"cps_url\": \"https://preview.twilio.com/TrustedComms/CurrentCall\",\"phone_number\": \"+1500123\",\"url\": \"https://preview.twilio.com/TrustedComms/CPS\"}" )); var response = CpsResource.Fetch(xXcnamSensitivePhoneNumber: Serialize("x_xcnam_sensitive_phone_number"), client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Get, Twilio.Rest.Domain.Preview, "/TrustedComms/CPS", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { CpsResource.Fetch(client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
public void TestFetchRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Get, Twilio.Rest.Domain.Preview, "/TrustedComms/CPS", "" ); request.AddHeaderParam("X-Xcnam-Sensitive-Phone-Number", Serialize("x_xcnam_sensitive_phone_number")); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { CpsResource.Fetch(xXcnamSensitivePhoneNumber: Serialize("x_xcnam_sensitive_phone_number"), client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }