public void GetTns2WithXmlTest() { using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10/tns?page=1&size=50000", Helper.AccountId), ContentToSend = new StringContent(TestXmlStrings.ValidSipPeerTnsResponseXml, Encoding.UTF8, "application/xml") })) { var client = Helper.CreateClient(); var peer = new SipPeer { Id = "10", SiteId = "1" }; peer.SetClient(client); var result = peer.GetTns().Result; if (server.Error != null) { throw server.Error; } Assert.AreEqual(17, result.Length); Assert.AreEqual("3034162216", result[0].FullNumber); Assert.AreEqual("3034162218", result[1].FullNumber); } }
public void UpdateTnsTest() { var item = new SipPeerTelephoneNumber { FullNumber = "Number", RewriteUser = "******" }; using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "PUT", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10/tns/00", Helper.AccountId), EstimatedContent = Helper.ToXmlString(item) })) { var client = Helper.CreateClient(); var peer = new SipPeer { Id = "10", SiteId = "1" }; peer.SetClient(client); peer.UpdateTns("00", item).Wait(); if (server.Error != null) { throw server.Error; } } }
public void GetTnsTest() { var item = new SipPeerTelephoneNumber { FullNumber = "Number", RewriteUser = "******" }; var response = new SipPeerTelephoneNumberResponse { SipPeerTelephoneNumber = item }; using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10/tns/00", Helper.AccountId), ContentToSend = Helper.CreateXmlContent(response) })) { var client = Helper.CreateClient(); var peer = new SipPeer { Id = "10", SiteId = "1" }; peer.SetClient(client); var result = peer.GetTns("00").Result; if (server.Error != null) { throw server.Error; } Helper.AssertObjects(item, result); } }
public void MoveTnsTest() { using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "POST", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10/movetns", Helper.AccountId), EstimatedContent = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<SipPeerTelephoneNumbers>\r\n <FullNumber>111</FullNumber>\r\n <FullNumber>222</FullNumber>\r\n</SipPeerTelephoneNumbers>" })) { var client = Helper.CreateClient(); var peer = new SipPeer { Id = "10", SiteId = "1" }; peer.SetClient(client); peer.MoveTns("111", "222").Wait(); if (server.Error != null) { throw server.Error; } } }