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.

42 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HttpClientStudy.UnitTest
{
/// <summary>
/// 基础HttpClient 测试
/// </summary>
public class NormalHttpClientTest
{
private readonly ITestOutputHelper _logger;
private readonly string baseAddress = "http://localhost:5189";
public NormalHttpClientTest(ITestOutputHelper outputHelper)
{
_logger = outputHelper;
}
[Fact]
public async Task GetAccount_Test()
{
HttpClient httpClient = new HttpClient()
{
BaseAddress = new Uri(TestConfig.WebApiBaseUrl),
};
var responseMessage = await httpClient.GetAsync("/api/Normal/GetAllAccounts");
responseMessage.EnsureSuccessStatusCode();
Assert.NotNull(responseMessage);
Assert.True(responseMessage.IsSuccessStatusCode);
var content = await responseMessage.Content.ReadAsStringAsync();
Assert.NotEmpty(content);
}
}
}