using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HttpClientStudy.UnitTest.Core { /// <summary> /// SimpleHttpClient 测试类 /// </summary> public class SimpleHttpClientTest { private readonly ITestOutputHelper _logger; public SimpleHttpClientTest(ITestOutputHelper outputHelper) { _logger = outputHelper; } [Fact] public void Get_Test() { SimpleHttpClient client = new SimpleHttpClient(); var result = client.Get("http://localhost:5000/api/Simple/GetAccount"); Assert.NotNull(result); Assert.NotEmpty(result); } [Fact] public void Test() { SimpleHttpClient client = new SimpleHttpClient(); var result = client.GetJson<BaseResult<string>>("http://localhost:5000/api/Simple/GetAccount"); Assert.NotNull(result); Assert.IsAssignableFrom<BaseResult>(result); Assert.Equal(1, result.Code); Assert.Contains("成功", result.Message); Assert.IsType<string>(result.Message); Assert.NotEmpty(result.Message); } } }