public void should_call_voice() { var resp = new Mock <IWebResponse>(); resp.Setup(e => e.GetResponseStream()).Returns(new MemoryStream(Encoding.UTF8.GetBytes("{\"call-id\":\"ffffffff36c53a6c37ba7bcfada6ffff-1\",\"to\":\"17775551212\",\"status\":\"0\"}"))); var postDataStream = new MemoryStream(); _request.Setup(e => e.GetRequestStream()).Returns(postDataStream); _request.Setup(e => e.GetResponse()).Returns(resp.Object); var result = Voice.Call(new Voice.CallCommand { to = "17775551212", answer_url = "https://test.test.com/content/voiceDemo.xml", from = "15555551212", }); _mock.Verify(h => h.CreateHttp(new Uri( string.Format("{0}/call/json", RestUrl))), Times.Once); postDataStream.Position = 0; var sr = new StreamReader(postDataStream); var postData = sr.ReadToEnd(); Assert.AreEqual(string.Format("to=17775551212&answer_url=https%3a%2f%2ftest.test.com%2fcontent%2fvoiceDemo.xml&from=15555551212&api_key={0}&api_secret={1}&", ApiKey, ApiSecret), postData); Assert.AreEqual("ffffffff36c53a6c37ba7bcfada6ffff-1", result.CallId); Assert.AreEqual("17775551212", result.to); Assert.AreEqual("0", result.status); }
public ActionResult Index() { Voice voice = new Voice(); voice.Call( TO("sip:[email protected]"), FROM("9065272450") ); voice.Say(ARRAY(new Say("Hello World"))); return(Content(voice.Render().ToString(), "application/json")); }
public void should_call_voice() { var result = Voice.Call(new Voice.CallCommand { to = "17775551212", answer_url = "https://abcdefgh.ngrok.io/content/voiceDemo.xml", status_url = "https://abcdefgh.ngrok.io/api/voice", from = "15555551212", }); Assert.IsNotEmpty(result.CallId); Assert.AreEqual("0", result.status); Assert.AreEqual("17775551212", result.to); }
public void GoogleVoiceTest() { // Send SMS text message. voice.SendSMS("3126234015", "this is a test of SharpVoice"); // Write SMS text messages to the console. foreach (Message msg in voice.SMS.Messages) { Console.WriteLine("[" + msg.type + "] " + msg.displayNumber + ": " + msg.Text); } string st = voice.Call("2194623737", "3126234015", "7146994015"); Console.WriteLine(st); foreach (Message msg in voice.Inbox.Messages) { Console.WriteLine("[" + msg.type + "] " + msg.displayNumber + ": " + msg.Duration.ToString() + " second(s)"); } Phone phone = new Phone(voice, ""); }