Interface ISimulatedHttp
Simulates HttpClient transactions for testing and providing mock data
Namespace: BlazorFocused.Tools
Assembly: BlazorFocused.Tools.dll
Syntax
public interface ISimulatedHttp
Properties
| Improve this Doc View SourceDelegatingHandler
Handler that can be passed into System.Net.Http.HttpClient for making simulated requests
Declaration
DelegatingHandler DelegatingHandler { get; }
Property Value
Type | Description |
---|---|
DelegatingHandler |
HttpClient
Returns System.Net.Http.HttpClient to perform requests
Declaration
HttpClient HttpClient { get; }
Property Value
Type | Description |
---|---|
HttpClient |
Methods
| Improve this Doc View SourceGetRequestHeaderValues(HttpMethod, String, String)
Retrieve header values under specified key for a given request
Declaration
IEnumerable<string> GetRequestHeaderValues(HttpMethod method, string url, string key)
Parameters
Type | Name | Description |
---|---|---|
HttpMethod | method | Http Method of which request was made |
System.String | url | Url of which request was made |
System.String | key | Header key for values to obtain |
Returns
Type | Description |
---|---|
IEnumerable<System.String> |
SetupDELETE(String)
Begin setup for an expected DELETE request that will be used
Declaration
ISimulatedHttpSetup SetupDELETE(string url)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Relative or full url expected request |
Returns
Type | Description |
---|---|
ISimulatedHttpSetup | Further configuration to handle simulated response object |
SetupGET(String)
Begin setup for an expected GET request that will be used
Declaration
ISimulatedHttpSetup SetupGET(string url)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Relative or full url expected request |
Returns
Type | Description |
---|---|
ISimulatedHttpSetup | Further configuration to handle simulated response object |
SetupPATCH(String, Object)
Begin setup for an expected PATCH request that will be used
Declaration
ISimulatedHttpSetup SetupPATCH(string url, object content = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Relative or full url expected request |
System.Object | content | Request body of expected request (will not compare if null) |
Returns
Type | Description |
---|---|
ISimulatedHttpSetup | Further configuration to handle simulated response object |
SetupPOST(String, Object)
Begin setup for an expected POST request that will be used
Declaration
ISimulatedHttpSetup SetupPOST(string url, object content = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Relative or full url expected request |
System.Object | content | Request body of expected request (will not compare if null) |
Returns
Type | Description |
---|---|
ISimulatedHttpSetup | Further configuration to handle simulated response object |
SetupPUT(String, Object)
Begin setup for an expected PUT request that will be used
Declaration
ISimulatedHttpSetup SetupPUT(string url, object content = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Relative or full url expected request |
System.Object | content | Request body of expected request (will not compare if null) |
Returns
Type | Description |
---|---|
ISimulatedHttpSetup | Further configuration to handle simulated response object |
VerifyDELETEWasCalled(String)
Verify a DELETE request was made
Declaration
void VerifyDELETEWasCalled(string url = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Expected relative or full url |
Exceptions
Type | Condition |
---|---|
BlazorFocused.Tools.SimulatedHttpTestException | Exception will be thrown if expected request was not performed |
VerifyGETWasCalled(String)
Verify a GET request was made
Declaration
void VerifyGETWasCalled(string url = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Expected relative or full url |
Exceptions
Type | Condition |
---|---|
BlazorFocused.Tools.SimulatedHttpTestException | Exception will be thrown if expected request was not performed |
VerifyPATCHWasCalled(String, Object)
Verify PATCH request was made
Declaration
void VerifyPATCHWasCalled(string url = null, object content = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Expected relative or full url |
System.Object | content | Expected request object |
Exceptions
Type | Condition |
---|---|
BlazorFocused.Tools.SimulatedHttpTestException | Exception will be thrown if expected request was not performed |
VerifyPOSTWasCalled(String, Object)
Verify POST request was made
Declaration
void VerifyPOSTWasCalled(string url = null, object content = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Expected relative or full url |
System.Object | content | Expected request object |
Exceptions
Type | Condition |
---|---|
BlazorFocused.Tools.SimulatedHttpTestException | Exception will be thrown if expected request was not performed |
VerifyPUTWasCalled(String, Object)
Verify PUT request was made
Declaration
void VerifyPUTWasCalled(string url = null, object content = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Expected relative or full url |
System.Object | content | Expected request object |
Exceptions
Type | Condition |
---|---|
BlazorFocused.Tools.SimulatedHttpTestException | Exception will be thrown if expected request was not performed |