Example #1
0
 /// <summary>
 /// Delete请求
 /// </summary>
 /// <param name="httpClient">http客户端</param>
 /// <param name="url">URL</param>
 /// <param name="customerOptions">自定义选项配置</param>
 /// <returns>任务</returns>
 public static Task <string> DeleteAsync(this HttpClient httpClient, string url, Action <ChannelCustomerOptions> customerOptions = null)
 {
     return(Task <string> .Run(() => httpClient.Delete(url, customerOptions)));
 }
        public void TestDelete()
        {
            using (var webservice = CreateRESTHttpService())
            {

                var client = new HttpClient();
                client.BaseAddress = webservice.BaseUri;

                // Builds: http://localhost:20259/RESTEmployeeService.svc/Del?id=1

                var uri = webservice.Uri("Del?id=1");

                var response = client.Delete(uri);

                Assert.True(response.IsSuccessStatusCode, response.ToString());
                Assert.True(response.Content.ReadAsString().Contains("true"));

            }
        }