public void MakeGetRequestTest()
 {
     using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = "/v1.0/test?test1=value1&test2=value2" }))
     {
         var client = Helper.CreateClient();
         client.MakeGetRequest("test",
                      new Dictionary<string, object> { { "test1", "value1" }, { "test2", "value2" } }, null, true)
                      .Wait();
         if (server.Error != null) throw server.Error;
     }
     
 }
 public void MakeGetRequestTTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "GET", 
         EstimatedPathAndQuery = "/v1.0/test?test1=value1&test2=value2",
         ContentToSend =  Helper.CreateXmlContent(new TestItem
         {
             Name = "Name",
             Flag = true
         })
     }))
     {
         var client = Helper.CreateClient();
         {
             var result = client.MakeGetRequest<TestItem>("test",
                 new Dictionary<string, object> { { "test1", "value1" }, { "test2", "value2" } }).Result;
             if (server.Error != null) throw server.Error;
             Assert.AreEqual("Name", result.Name);
             Assert.IsTrue(result.Flag != null && result.Flag.Value);
         }
     }
 }
        public void SendDataWithByteArrayTest()
        {
            var data = Encoding.UTF8.GetBytes("hello");
            using (var server = new HttpServer(new RequestHandler
            {
                EstimatedMethod = "PUT",
                EstimatedPathAndQuery = "/v1.0/test",
                EstimatedContent = "hello",
                EstimatedHeaders = new Dictionary<string, string> { { "Content-Type", "media/type" } }
            }))
            {
                var client = Helper.CreateClient();
                client.SendData("test", data, "media/type", "PUT", true).Wait();
                if (server.Error != null) throw server.Error;
            }

        }
 public void AuthHeaderTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "GET",
         EstimatedHeaders = new Dictionary<string, string> { { "Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", Helper.UserName, Helper.Password)))} },
         ContentToSend = Helper.CreateXmlContent(new SitesResponse())
     }))
     {
         var client = Helper.CreateClient();
         {
             Site.List(client).Wait();
             if (server.Error != null) throw server.Error;
         }
     }
 }
 public void MakeDeleteRequestTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "DELETE",
         EstimatedPathAndQuery = "/v1.0/test"
     }))
     {
         var client = Helper.CreateClient();
         {
             client.MakeDeleteRequest("test").Wait();
             if (server.Error != null) throw server.Error;
         }
     }
 }
        public void MakePostRequestTTest()
        {
            using (var server = new HttpServer(new RequestHandler
            {
                EstimatedMethod = "POST",
                EstimatedPathAndQuery = "/v1.0/test",
                EstimatedContent = Helper.ToXmlString(new TestModel{Test = true}),
                ContentToSend = Helper.CreateXmlContent(new TestItem
                {
                    Name = "Name",
                    Flag = true
                })
            }))
            {
                var client = Helper.CreateClient();
                {
                    var result = client.MakePostRequest<TestItem>("test", new TestModel{ Test = true }).Result;
                    if (server.Error != null) throw server.Error;
                    Assert.AreEqual("Name", result.Name);
                    Assert.IsTrue(result.Flag != null && result.Flag.Value);
                }
            }

        }
 public void MakePutRequestTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "PUT",
         EstimatedPathAndQuery = "/v1.0/test",
         EstimatedContent = Helper.ToXmlString(new TestModel { Test = true })
     }))
     {
         var client = Helper.CreateClient();
         {
             client.MakePutRequest("test", new TestModel { Test = true }, true).Wait();
             if (server.Error != null) throw server.Error;
         }
     }
 }