Class HttpClientExtensions
a set of extensions to the httpclient in order to facilitate route-less integration testing
Inheritance
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public static class HttpClientExtensions
Methods
DELETEAsync<TEndpoint, TRequest>(HttpClient, TRequest)
make a DELETE request to an endpoint using auto route discovery using a request dto that does not send back a response dto.
Declaration
public static async Task<HttpResponseMessage> DELETEAsync<TEndpoint, TRequest>(this HttpClient client, TRequest request)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TRequest | the type of the request dto |
DELETEAsync<TRequest, TResponse>(HttpClient, String, TRequest)
make a DELETE request using a request dto and get back a response dto.
Declaration
public static async Task<TestResult<TResponse>> DELETEAsync<TRequest, TResponse>(this HttpClient client, string requestUri, TRequest request)
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
System.String | requestUri | the route url to post to |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TRequest | type of the requet dto |
TResponse | type of the response dto |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | thrown when the response body cannot be deserialized in to specified response dto type |
DELETEAsync<TEndpoint, TResponse>(HttpClient)
make a DELETE request to an endpoint using auto route discovery without a request dto and get back a typed response dto.
Declaration
public static Task<TestResult<TResponse>> DELETEAsync<TEndpoint, TResponse>(this HttpClient client)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TResponse | the type of the response dto |
DELETEAsync<TEndpoint, TRequest, TResponse>(HttpClient, TRequest)
make a DELETE request to an endpoint using auto route discovery using a request dto and get back a response dto.
Declaration
public static Task<TestResult<TResponse>> DELETEAsync<TEndpoint, TRequest, TResponse>(this HttpClient client, TRequest request)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TRequest | the type of the request dto |
TResponse | the type of the response dto |
GETAsync<TEndpoint, TRequest>(HttpClient, TRequest)
make a GET request to an endpoint using auto route discovery using a request dto that does not send back a response dto.
Declaration
public static async Task<HttpResponseMessage> GETAsync<TEndpoint, TRequest>(this HttpClient client, TRequest request)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TRequest | the type of the request dto |
GETAsync<TRequest, TResponse>(HttpClient, String, TRequest)
make a GET request using a request dto and get back a response dto.
Declaration
public static async Task<TestResult<TResponse>> GETAsync<TRequest, TResponse>(this HttpClient client, string requestUri, TRequest request)
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
System.String | requestUri | the route url to post to |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TRequest | type of the requet dto |
TResponse | type of the response dto |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | thrown when the response body cannot be deserialized in to specified response dto type |
GETAsync<TEndpoint, TResponse>(HttpClient)
make a GET request to an endpoint using auto route discovery without a request dto and get back a typed response dto.
Declaration
public static Task<TestResult<TResponse>> GETAsync<TEndpoint, TResponse>(this HttpClient client)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TResponse | the type of the response dto |
GETAsync<TEndpoint, TRequest, TResponse>(HttpClient, TRequest)
make a GET request to an endpoint using auto route discovery using a request dto and get back a response dto.
Declaration
public static Task<TestResult<TResponse>> GETAsync<TEndpoint, TRequest, TResponse>(this HttpClient client, TRequest request)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TRequest | the type of the request dto |
TResponse | the type of the response dto |
POSTAsync<TEndpoint, TRequest>(HttpClient, TRequest)
make a POST request to an endpoint using auto route discovery using a request dto that does not send back a response dto.
Declaration
public static async Task<HttpResponseMessage> POSTAsync<TEndpoint, TRequest>(this HttpClient client, TRequest request)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TRequest | the type of the request dto |
POSTAsync<TRequest, TResponse>(HttpClient, String, TRequest)
make a POST request using a request dto and get back a response dto.
Declaration
public static async Task<TestResult<TResponse>> POSTAsync<TRequest, TResponse>(this HttpClient client, string requestUri, TRequest request)
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
System.String | requestUri | the route url to post to |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TRequest | type of the requet dto |
TResponse | type of the response dto |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | thrown when the response body cannot be deserialized in to specified response dto type |
POSTAsync<TEndpoint, TResponse>(HttpClient)
make a POST request to an endpoint using auto route discovery without a request dto and get back a typed response dto.
Declaration
public static Task<TestResult<TResponse>> POSTAsync<TEndpoint, TResponse>(this HttpClient client)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TResponse | the type of the response dto |
POSTAsync<TEndpoint, TRequest, TResponse>(HttpClient, TRequest)
make a POST request to an endpoint using auto route discovery using a request dto and get back a response dto.
Declaration
public static Task<TestResult<TResponse>> POSTAsync<TEndpoint, TRequest, TResponse>(this HttpClient client, TRequest request)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TRequest | the type of the request dto |
TResponse | the type of the response dto |
PUTAsync<TEndpoint, TRequest>(HttpClient, TRequest)
make a PUT request to an endpoint using auto route discovery using a request dto that does not send back a response dto.
Declaration
public static async Task<HttpResponseMessage> PUTAsync<TEndpoint, TRequest>(this HttpClient client, TRequest request)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TRequest | the type of the request dto |
PUTAsync<TRequest, TResponse>(HttpClient, String, TRequest)
make a PUT request using a request dto and get back a response dto.
Declaration
public static async Task<TestResult<TResponse>> PUTAsync<TRequest, TResponse>(this HttpClient client, string requestUri, TRequest request)
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
System.String | requestUri | the route url to post to |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TRequest | type of the requet dto |
TResponse | type of the response dto |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | thrown when the response body cannot be deserialized in to specified response dto type |
PUTAsync<TEndpoint, TResponse>(HttpClient)
make a PUT request to an endpoint using auto route discovery without a request dto and get back a typed response dto.
Declaration
public static Task<TestResult<TResponse>> PUTAsync<TEndpoint, TResponse>(this HttpClient client)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TResponse | the type of the response dto |
PUTAsync<TEndpoint, TRequest, TResponse>(HttpClient, TRequest)
make a PUT request to an endpoint using auto route discovery using a request dto and get back a response dto.
Declaration
public static Task<TestResult<TResponse>> PUTAsync<TEndpoint, TRequest, TResponse>(this HttpClient client, TRequest request)
where TEndpoint : IEndpoint
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpClient | client | |
TRequest | request | the request dto |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TestResult<TResponse>> |
Type Parameters
Name | Description |
---|---|
TEndpoint | the type of the endpoint |
TRequest | the type of the request dto |
TResponse | the type of the response dto |