Exemple #1
0
 public void GetWithErrorXmlTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "GET",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/tnreservation/1", Helper.AccountId),
         ContentToSend = new StringContent(TestXmlStrings.InvalidReservationResponseXml, Encoding.UTF8, "application/xml")
     }))
     {
         var client = Helper.CreateClient();
         try
         {
             TnReservation.Get(client, "1").Wait();
             if (server.Error != null)
             {
                 throw server.Error;
             }
         }
         catch (AggregateException exc)
         {
             var ex = exc.InnerExceptions[0] as BandwidthIrisException;
             if (ex != null)
             {
                 Assert.AreEqual("Reservation failed: telephone number 9195551212 is not available.", ex.Message);
                 Assert.AreEqual("5041", ex.Code);
                 return;
             }
         }
         Assert.Fail("should throw an error");
     }
 }
Exemple #2
0
        public void GetTest()
        {
            var item = new TnReservation
            {
                Id                 = "1",
                AccountId          = "111",
                ReservedTn         = new[] { "000" },
                ReservationExpires = 0
            };

            using (var server = new HttpServer(new RequestHandler
            {
                EstimatedMethod = "GET",
                EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/tnreservation/1", Helper.AccountId),
                ContentToSend = Helper.CreateXmlContent(new ReservationResponse {
                    Reservation = item
                })
            }))
            {
                var client = Helper.CreateClient();
                var result = TnReservation.Get(client, "1").Result;
                if (server.Error != null)
                {
                    throw server.Error;
                }
                Helper.AssertObjects(item, result);
            }
        }
Exemple #3
0
 public void GetWithXmlTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "GET",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/tnreservation/1", Helper.AccountId),
         ContentToSend = new StringContent(TestXmlStrings.ValidReservationResponseXml, Encoding.UTF8, "application/xml")
     }))
     {
         var client = Helper.CreateClient();
         var result = TnReservation.Get(client, "1").Result;
         if (server.Error != null)
         {
             throw server.Error;
         }
         Assert.AreEqual("1", result.Id);
         Assert.AreEqual("accountId", result.AccountId);
         Assert.AreEqual(30, result.ReservationExpires);
         Assert.AreEqual("9195551212", result.ReservedTn[0]);
     }
 }