Ejemplo n.º 1
0
        public void ShouldRedirectCall()
        {
            var  client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);
            var  originalFriendlyName = "http://devin.webscript.io/twilioconf?conf=" + Utilities.MakeRandomFriendlyName();
            Call originalCall         = client.InitiateOutboundCall("+13144586142", "+13215946383", originalFriendlyName);

            Assert.IsNotNull(originalCall.Sid);

            var callSid = originalCall.Sid;

            int counter = 0;

            while (counter < 10)
            {
                Thread.Sleep(1000);

                var updatedcall = client.GetCall(callSid);
                if (updatedcall.Status == "")
                {
                    break;
                }

                counter++;
            }

            ConferenceResult conferences = client.ListConferences();

            Assert.IsNotNull(conferences);
            Assert.IsNull(conferences.RestException);
            Assert.IsNotNull(conferences.Conferences);

            Conference conference = conferences.Conferences.FirstOrDefault(c => c.FriendlyName == originalFriendlyName);

            Assert.IsNotNull(conference);
            Assert.IsNotNull(conference.Sid);

            Participant participant = client.GetConferenceParticipant(conference.Sid, callSid);

            var redirectedFriendlyName = Utilities.MakeRandomFriendlyName();

            client.RedirectCall(originalCall.Sid, "http://devin.webscript.io/twilioconf?conf=" + redirectedFriendlyName, "GET");

            conferences = client.ListConferences();

            Assert.IsNotNull(conferences);
            Assert.IsNull(conferences.RestException);
            Assert.IsNotNull(conferences.Conferences);

            conference = conferences.Conferences.FirstOrDefault(c => c.FriendlyName == redirectedFriendlyName);

            Assert.IsNotNull(conference);
            Assert.IsNotNull(conference.Sid);

            participant = client.GetConferenceParticipant(conference.Sid, callSid);

            Assert.AreEqual(callSid, participant.CallSid);

            client.HangupCall(originalCall.Sid, HangupStyle.Completed);
        }
Ejemplo n.º 2
0
        public void ShouldListConferenceAsynchronouslyUsingFilters()
        {
            manualResetEvent = new ManualResetEvent(false);

            var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);

            ConferenceListRequest options = new ConferenceListRequest();
            ConferenceResult      result  = null;

            client.ListConferences(options, conferences => {
                result = conferences;
                manualResetEvent.Set();
            });

            manualResetEvent.WaitOne();

            Assert.Fail();
        }
Ejemplo n.º 3
0
        public void ShouldListConferencesAsynchronously()
        {
            manualResetEvent = new ManualResetEvent(false);

            var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);

            ConferenceResult result = null;

            client.ListConferences(conferences => {
                result = conferences;
                manualResetEvent.Set();
            });

            manualResetEvent.WaitOne();

            Assert.IsNotNull(result);
            Assert.IsNull(result.RestException);
            Assert.IsNotNull(result.Conferences);
        }