public void TestCreateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"result\": \"valid\"}" )); var response = SinkValidateResource.Create("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "test_id", client: twilioRestClient); Assert.NotNull(response); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Events, "/v1/Sinks/DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Validate", "" ); request.AddPostParam("TestId", Serialize("test_id")); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { SinkValidateResource.Create("DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "test_id", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }