Esempio n. 1
0
 public void GetHistoryTest()
 {
     using (var server = new HttpServer(new[]
     {
         new RequestHandler
         {
             EstimatedMethod = "GET",
             EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/lsrorders/1/history", Helper.AccountId),
             ContentToSend = new StringContent(TestXmlStrings.OrderHistory, Encoding.UTF8, "application/xml")
         }
     }))
     {
         var client = Helper.CreateClient();
         var i      = new LsrOrder {
             Id = "1"
         };
         i.SetClient(client);
         var result = i.GetHistory().Result;
         if (server.Error != null)
         {
             throw server.Error;
         }
         Assert.IsTrue(result.Length > 0);
     }
 }
Esempio n. 2
0
 public void GetNotesTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "GET",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/lsrorders/1/notes", Helper.AccountId),
         ContentToSend = new StringContent(TestXmlStrings.NotesResponse, Encoding.UTF8, "application/xml")
     }))
     {
         var client = Helper.CreateClient();
         var order  = new LsrOrder {
             Id = "1"
         };
         order.SetClient(client);
         var list = order.GetNotes().Result;
         if (server.Error != null)
         {
             throw server.Error;
         }
         Assert.AreEqual(2, list.Length);
         Assert.AreEqual("11299", list[0].Id);
         Assert.AreEqual("customer", list[0].UserId);
         Assert.AreEqual("Test", list[0].Description);
         Assert.AreEqual("11301", list[1].Id);
         Assert.AreEqual("customer", list[1].UserId);
         Assert.AreEqual("Test1", list[1].Description);
     }
 }
Esempio n. 3
0
        public void AddNoteTest()
        {
            var item = new Note
            {
                UserId      = "customer",
                Description = "Test"
            };

            using (var server = new HttpServer(new[] {
                new RequestHandler
                {
                    EstimatedMethod = "POST",
                    EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/lsrorders/1/notes", Helper.AccountId),
                    EstimatedContent = Helper.ToXmlString(item),
                    HeadersToSend = new Dictionary <string, string> {
                        { "Location", string.Format("/v1.0/accounts/{0}/lsrorders/1/notes/11299", Helper.AccountId) }
                    }
                },
                new RequestHandler
                {
                    EstimatedMethod = "GET",
                    EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/lsrorders/1/notes", Helper.AccountId),
                    ContentToSend = new StringContent(TestXmlStrings.NotesResponse, Encoding.UTF8, "application/xml")
                }
            }))
            {
                var client = Helper.CreateClient();
                var order  = new LsrOrder {
                    Id = "1"
                };
                order.SetClient(client);
                var r = order.AddNote(item).Result;
                if (server.Error != null)
                {
                    throw server.Error;
                }
                Assert.AreEqual("11299", r.Id);
                Assert.AreEqual("customer", r.UserId);
                Assert.AreEqual("Test", r.Description);
            }
        }