示例#1
0
        /// <summary>
        /// Gets the intro.
        /// </summary>
        private static byte[] GetIntro()
        {
            var script = ApidazeScript.Build();

            var intro = script.AddNode(Ringback.FromFile(SERVER_URL + PLAYBACK_PATH)).AddNode(Wait.SetDuration(2))
                        .AddNode(new Answer()).AddNode(new Record {
                Name = "example_recording"
            }).AddNode(Wait.SetDuration(2))
                        .AddNode(Playback.FromFile(SERVER_URL + PLAYBACK_PATH))
                        .AddNode(Speak.WithText("This example script will show you some things you can do with our API"))
                        .AddNode(Wait.SetDuration(2)).AddNode(
                new Speak
            {
                DigitTimeoutMillis = TimeSpan.FromSeconds(15).TotalMilliseconds,
                InputTimeoutMillis = TimeSpan.FromSeconds(15).TotalMilliseconds,
                Text  = "Press 1 for an example of text to speech, press 2 to enter an echo line to check voice latency or press 3 to enter a conference.",
                Binds = new List <object>
                {
                    new Bind {
                        Action = SERVER_URL + STEP_1_PATH, Value = "1"
                    },
                    new Bind {
                        Action = SERVER_URL + STEP_2_PATH, Value = "2"
                    },
                    new Bind {
                        Action = SERVER_URL + STEP_3_PATH, Value = "3"
                    },
                },
            })
                        .ToXml();

            return(Encoding.UTF8.GetBytes(intro));
        }
示例#2
0
        public void ToXml_Ringback_ReturnsEqualToFile()
        {
            // Arrange
            var expectedOutput = GetFileContents("ringback.xml");

            _ApidazeScript.AddNode(new Answer())
            .AddNode(Ringback.FromFile("http://www.mydomain.com/welcome.wav"))
            .AddNode(new Dial {
                Sipaccount = new List <SipAccount>()
                {
                    new SipAccount("bob")
                }
            })
            .AddNode(new Hangup());
            const bool noFormatting = true;

            // Act
            var result = _ApidazeScript.ToXml(noFormatting, true);

            // Assert
            result.Should().BeEquivalentTo(expectedOutput);
        }