using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Util.Http;
namespace Util.Tests.Infrastructure;
///
/// 控制器测试基类
///
public abstract class ControllerTestBase {
///
/// 测试初始化
///
protected ControllerTestBase( IHttpClient client, IHttpContextAccessor accessor = null ) {
Client = client;
if ( accessor != null )
Context = accessor.HttpContext;
}
///
/// Http客户端
///
protected IHttpClient Client { get; }
///
/// Http上下文
///
protected HttpContext Context { get; }
///
/// Http Get操作
///
/// 服务地址
/// 参数
protected async Task> GetAsync( string url, object data = null ) {
return await Client.Get>( url, data ).GetResultAsync();
}
///
/// Http Get操作
///
/// 返回结果类型
/// 服务地址
/// 参数
protected async Task> GetAsync( string url, object data = null ) {
return await Client.Get>( url,data ).GetResultAsync();
}
///
/// Http Post操作
///
/// 服务地址
/// 参数
protected async Task> PostAsync( string url, object data ) {
return await PostAsync