You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HttpClientStudy.UnitTest.HttpResponses
|
|
{
|
|
public class HttpResponseContentTest
|
|
{
|
|
private readonly ITestOutputHelper _output;
|
|
|
|
public HttpResponseContentTest(ITestOutputHelper testOutput)
|
|
{
|
|
_output = testOutput;
|
|
}
|
|
|
|
[Fact]
|
|
public void Test()
|
|
{
|
|
HttpClient client = new HttpClient();
|
|
|
|
var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(new { Name="sdfsdf"}), Encoding.UTF8, System.Net.Mime.MediaTypeNames.Application.Json);
|
|
|
|
client.PostAsync("http://www.baidu.com", content);
|
|
}
|
|
|
|
[Fact]
|
|
public async void Test2()
|
|
{
|
|
HttpClient client = new HttpClient();
|
|
|
|
var dd = await client.PostAsJsonAsync("url", new { Name = "" }, CancellationToken.None);
|
|
}
|
|
}
|
|
|
|
public class Demo
|
|
{
|
|
public string Name { get; set; }
|
|
public string Description { get; set; }
|
|
}
|
|
}
|