Beispiel #1
0
 public static async Task <TnReservation> Create(Client client, TnReservation item)
 {
     using (var response = await client.MakePostRequest(client.ConcatAccountPath(TnReservationPath), item))
     {
         return(await Get(client, client.GetIdFromLocationHeader(response.Headers.Location)));
     }
 }
 public static async Task<TnReservation> Create(Client client, TnReservation item)
 {
     using (var response = await client.MakePostRequest(client.ConcatAccountPath(TnReservationPath), item))
     {
         return await Get(client, client.GetIdFromLocationHeader(response.Headers.Location));
     }
 }
 public void GetTest()
 {
     var item = new TnReservation
     {
         Id = "1",
         AccountId = "111",
         ReservedTn = "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);
     }
 }
Beispiel #4
0
 public static Task <TnReservation> Create(TnReservation item)
 {
     return(Create(Client.GetInstance(), item));
 }
 public void DeleteTest()
 {
     using (var server = new HttpServer(new[]
     {
         new RequestHandler
         {
             EstimatedMethod = "DELETE",
             EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/tnreservation/1", Helper.AccountId),
         }
     }))
     {
         var client = Helper.CreateClient();
         var i = new TnReservation { Id = "1" };
         i.SetClient(client);
         i.Delete().Wait();
         if (server.Error != null) throw server.Error;
     }
 }
        public void CreateWithDefaultClientTest()
        {
            var item = new TnReservation
            {
                AccountId = "111",
                ReservedTn = "000",
                ReservationExpires = 0
            };


            using (var server = new HttpServer(new[]
            {
                new RequestHandler
                {
                    EstimatedMethod = "POST",
                    EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/tnreservation", Helper.AccountId),
                    EstimatedContent = Helper.ToXmlString(item),
                    HeadersToSend =
                        new Dictionary<string, string>
                        {
                            {"Location", string.Format("/v1.0/accounts/{0}/tnreservation/1", Helper.AccountId)}
                        }
                },
                new RequestHandler
                {
                    EstimatedMethod = "GET",
                    EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/tnreservation/1", Helper.AccountId),
                    ContentToSend = Helper.CreateXmlContent(new ReservationResponse{Reservation = new TnReservation {Id = "1"}})
                }
            }))
            {
                var i = TnReservation.Create(item).Result;
                if (server.Error != null) throw server.Error;
                Assert.AreEqual("1", i.Id);
            }
        }
 public static Task<TnReservation> Create(TnReservation item)
 {
     return Create(Client.GetInstance(), item);
 }