예제 #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,
                         "{\"sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"from\": \"+15000000000\",\"to\": \"+573000000000\",\"reason\": \"Hello Jhon, your appointment has been confirmed.\",\"created_at\": \"2019-05-01T20:00:00Z\",\"url\": \"https://preview.twilio.com/TrustedComms/Business/PhoneCalls\"}"
                         ));

            var response = PhoneCallResource.Create("from", "to", client: twilioRestClient);

            Assert.NotNull(response);
        }
        public void TestCreateResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.Created,
                         "{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"bg_color\": \"#fff\",\"brand_sid\": \"BZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"branded_channel_sid\": \"BWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"business_sid\": \"BXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"caller\": \"Owl Bank\",\"created_at\": \"2019-05-01T20:00:00Z\",\"font_color\": \"#000\",\"from\": \"+15000000000\",\"logo\": \"https://www.twilio.com/marketing/bundles/company/img/logos/red/twilio-logo-red.png\",\"phone_number_sid\": \"PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reason\": \"Hello Jhon, your appointment has been confirmed.\",\"sid\": \"CQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"status\": \"unknown\",\"to\": \"+573000000000\",\"url\": \"https://preview.twilio.com/TrustedComms/Business/PhoneCalls\",\"use_case\": \"conversational\"}"
                         ));

            var response = PhoneCallResource.Create("from", "to", client: twilioRestClient);

            Assert.NotNull(response);
        }
예제 #3
0
        public void TestCreateRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Post,
                Twilio.Rest.Domain.Preview,
                "/TrustedComms/Business/PhoneCalls",
                ""
                );

            request.AddPostParam("From", Serialize("from"));
            request.AddPostParam("To", Serialize("to"));
            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                PhoneCallResource.Create("from", "to", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }