コード例 #1
0
        public void TestCreateResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.Created,
                         "{\"start_day\": \"start_day\",\"job_sid\": \"JSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"friendly_name\": \"friendly_name\",\"webhook_method\": \"webhook_method\",\"details\": {},\"end_day\": \"end_day\",\"webhook_url\": \"webhook_url\",\"email\": \"email\",\"resource_type\": \"resource_type\"}"
                         ));

            var response = ExportCustomJobResource.Create("resource_type", "start_day", "end_day", "friendly_name", client: twilioRestClient);

            Assert.NotNull(response);
        }
コード例 #2
0
        public void TestCreateRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Post,
                Twilio.Rest.Domain.Bulkexports,
                "/v1/Exports/resource_type/Jobs",
                ""
                );

            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                ExportCustomJobResource.Create("resource_type", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
コード例 #3
0
        public void TestCreateRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Post,
                Twilio.Rest.Domain.Preview,
                "/BulkExports/Exports/resource_type/Jobs",
                ""
                );

            request.AddPostParam("StartDay", Serialize("start_day"));
            request.AddPostParam("EndDay", Serialize("end_day"));
            request.AddPostParam("FriendlyName", Serialize("friendly_name"));
            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                ExportCustomJobResource.Create("resource_type", "start_day", "end_day", "friendly_name", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }