Interface IHttpMockBuilder

Fluent builder for a routed HTTP mock (.WithHttpResponse(r => r.OnGet(...).OnPost(...).Default(...))).

Namespace: BlazorToolkit.Previews
Assembly: BlazorToolkit.Previews.dll
Syntax
public interface IHttpMockBuilder

Methods

Default(Action<IHttpResponseBuilder>)

Sets the fallback response for requests no rule matched.

Declaration
IHttpMockBuilder Default(Action<IHttpResponseBuilder> respond)
Parameters
Type Name Description
Action<IHttpResponseBuilder> respond
Returns
Type Description
IHttpMockBuilder

On(string, string, Action<IHttpResponseBuilder>)

Adds a rule for the given method and path pattern.

Declaration
IHttpMockBuilder On(string method, string pathPattern, Action<IHttpResponseBuilder> respond)
Parameters
Type Name Description
string method
string pathPattern
Action<IHttpResponseBuilder> respond
Returns
Type Description
IHttpMockBuilder

OnDelete(string, Action<IHttpResponseBuilder>)

Adds a rule matching DELETE requests to pathPattern.

Declaration
IHttpMockBuilder OnDelete(string pathPattern, Action<IHttpResponseBuilder> respond)
Parameters
Type Name Description
string pathPattern
Action<IHttpResponseBuilder> respond
Returns
Type Description
IHttpMockBuilder

OnGet(string, Action<IHttpResponseBuilder>)

Adds a rule matching GET requests to pathPattern.

Declaration
IHttpMockBuilder OnGet(string pathPattern, Action<IHttpResponseBuilder> respond)
Parameters
Type Name Description
string pathPattern
Action<IHttpResponseBuilder> respond
Returns
Type Description
IHttpMockBuilder

OnPost(string, Action<IHttpResponseBuilder>)

Adds a rule matching POST requests to pathPattern.

Declaration
IHttpMockBuilder OnPost(string pathPattern, Action<IHttpResponseBuilder> respond)
Parameters
Type Name Description
string pathPattern
Action<IHttpResponseBuilder> respond
Returns
Type Description
IHttpMockBuilder

OnPut(string, Action<IHttpResponseBuilder>)

Adds a rule matching PUT requests to pathPattern.

Declaration
IHttpMockBuilder OnPut(string pathPattern, Action<IHttpResponseBuilder> respond)
Parameters
Type Name Description
string pathPattern
Action<IHttpResponseBuilder> respond
Returns
Type Description
IHttpMockBuilder