public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"id\": \"DataTaps.TestEventSchema\",\"schema_version\": 1,\"date_created\": \"2015-07-30T20:00:00Z\",\"url\": \"https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions/1\",\"raw\": \"https://events-schemas.twilio.com/DataTaps.TestEventSchema/1\"}" )); var response = VersionResource.Fetch("id", 1, client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Get, Twilio.Rest.Domain.Events, "/v1/Schemas/id/Versions/1", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { VersionResource.Fetch("id", 1, client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }