我有下面的代码来设置其余客户端。但在升级到 .NET 8 并将 RestSharpt 升级到最新版本后,RestResponse 给出错误,提示“没有给出与 RestResponse 所需参数请求相对应的参数”。 我的代码。
var response = new RestResponse<T>()
{
StatusCode = statusCode,
Data = dataResult,
RawBytes = rawBytesResult
};
mockClient.Setup(x => x.CallHttpClient<T>(It.IsAny<RestRequest>())).Returns(Task.FromResult(response));
下面的代码修复了错误
var response = new RestResponse<T>(new RestRequest("apitest/test", Method.Get))
{
StatusCode = statusCode,
Data = dataResult,
RawBytes = rawBytesResult
};
mockClient.Setup(x => x.CallHttpClient<T>(It.IsAny<RestRequest>())).Returns(Task.FromResult(response));