|
PeanutButter
|
Builds an http request. More...
Public Member Functions | |
| HttpRequestBuilder () | |
| void | WithJsonEncoder (Func< object, string > encoder) |
| Sets up a JSON encoder to use on this instance of HttpRequestBuilder only, to be used when generating a request body as JSON from an object. | |
| override HttpRequestBuilder | Randomize () |
| Randomizes the output. | |
| HttpRequestBuilder | WithRemoteAddress (string ipAddress) |
| Sets the HttpContext.Connection.RemoteIpAddress value. | |
| HttpRequestBuilder | WithRemoteAddress (IPAddress address) |
| Sets the HttpContext.Connection.RemoteIpAddress value. | |
| HttpRequestBuilder | WithRandomForm () |
| Adds a random form to the request. | |
| HttpRequestBuilder | WithRandomMethod () |
| Selects a random http method for the request. | |
| HttpRequestBuilder | WithRandomScheme () |
| Selects a random scheme (http|https) for the request. | |
| HttpRequestBuilder | WithRandomPath () |
| Selects a random path for the request. | |
| HttpRequestBuilder | WithRandomHost () |
| Selects a random hostname for the request. | |
| HttpRequestBuilder | WithRandomPort () |
| Selects a random port (80-10000) for the request. | |
| HttpRequestBuilder | WithRandomHeaders () |
| Adds some random X- prefixed headers for the request. | |
| HttpRequestBuilder | WithRandomCookies () |
| Adds some random cookies to the request. | |
| HttpRequestBuilder | WithBody (string body) |
| Sets the body for the request. If possible, form elements are derived from the body. | |
| HttpRequestBuilder | WithJsonBody< T > (T data) |
| HttpRequestBuilder | WithBody (byte[] body) |
| Sets the body for the request. If possible, form elements are derived from the body. | |
| HttpRequestBuilder | WithBody (Stream body) |
| Sets the body for the request. If possible, form elements are derived from the body. | |
| HttpRequestBuilder | WithCookie (string name, string value) |
| Sets a cookie on the request. Will overwrite an existing cookie with the same name. | |
| HttpRequestBuilder | WithCookies (IDictionary< string, string > cookies) |
| Sets a bunch of cookies on the request. Will overwrite existing cookies with the same name. Will not remove any other existing cookies. | |
| HttpRequestBuilder | WithNoCookies () |
| Clears cookies on the request. | |
| HttpRequestBuilder | WithCookies (IRequestCookieCollection cookies) |
| Sets the cookie collection on the request. | |
| HttpRequestBuilder | WithNoHeaders () |
| Clears headers on the request. | |
| HttpRequestBuilder | WithHeader (string header, string value) |
| Sets a header on the request. Any existing header with the same name is overwritten. | |
| HttpRequestBuilder | WithHeaders (IDictionary< string, string > headers) |
| Sets a bunch of headers on the request. Existing cookies with the same names are overwritten. Other existing cookies are left intact. | |
| HttpRequestBuilder | WithHeaders (IHeaderDictionary headers) |
| Sets the header dictionary on the request. | |
| HttpRequestBuilder | WithQuery (IQueryCollection query) |
| Sets the query collection on the request. | |
| HttpRequestBuilder | WithQueryParameter (string key, string value) |
| Sets a query parameter on the request. | |
| HttpRequestBuilder | WithQueryParameters (IDictionary< string, string > parameters) |
| Set multiple query parameters from a dictionary. | |
| HttpRequestBuilder | WithPath (string path) |
| HttpRequestBuilder | WithBasePath (string basePath) |
| Sets the base path on the request. | |
| HttpRequestBuilder | WithHost (HostString host) |
| Sets the host on the path. | |
| HttpRequestBuilder | WithPort (int port) |
| Sets the port on the request. | |
| HttpRequestBuilder | WithHost (string host) |
| Sets the host on the request. | |
| HttpRequestBuilder | WithQueryString (string queryString) |
| Sets the query string on the request. | |
| HttpRequestBuilder | WithQueryString (QueryString queryString) |
| Sets the query string on the request. | |
| HttpRequestBuilder | WithScheme (string scheme) |
| Sets the scheme on the request. | |
| HttpRequestBuilder | WithMethod (HttpMethod method) |
| Sets the method on the request. | |
| HttpRequestBuilder | WithMethod (string method) |
| Sets the method on the request. | |
| HttpRequestBuilder | WithHttpContext (HttpContext context) |
| Sets the http context on the request. | |
| HttpRequestBuilder | WithHttpContext (Func< HttpContext > accessor) |
| Sets the http context accessor on the request. | |
| HttpRequestBuilder | WithForm (IFormCollection formCollection) |
| Sets the form on the request. | |
| HttpRequestBuilder | WithFormField (string key, string value) |
| Set a field on the form of the request. | |
| HttpRequestBuilder | WithFormFields (IDictionary< string, string > fields) |
| Sets a collection of fields on the form of the request. | |
| HttpRequestBuilder | WithFormFile (IFormFile file) |
| Adds a file to the form of the request. | |
| HttpRequestBuilder | WithFormFile (string content, string name, string fileName) |
| Adds a form file with string content and the provided name and filename. | |
| HttpRequestBuilder | WithFormFile (byte[] content, string name, string fileName) |
| Adds a form file with binary content and the provided name and filename. | |
| HttpRequestBuilder | WithUrl (string url) |
| Set the full url for the request. | |
| HttpRequestBuilder | WithUrl (Uri url) |
| Set the full url for the request. | |
| HttpRequestBuilder | WithFormFile (Stream content, string name, string fileName) |
| Adds a form file with text content and the provided name and filename. | |
| HttpRequestBuilder | WithContentType (string contentType) |
| Sets the Content-Type header for the request. Note that this shouldn't be necessary most of the time - automatic content type detection is provided for requests with forms or JSON bodies. | |
| HttpRequestBuilder | WithSelfOrigin () |
| Sets the origin header to be the root of the request's uri. | |
| HttpRequestBuilder | WithRandomUrl () |
| Sets a random url for this request. | |
| HttpRequestBuilder | WithOrigin (string origin) |
| Sets the Origin header. | |
| HttpRequestBuilder | WithHttpContextMutator (Action< FakeHttpContext > mutator) |
| Facilitates easier http context mutations. | |
| Public Member Functions inherited from PeanutButter.TestUtils.AspNetCore.Builders.RandomizableBuilder< TBuilder, TSubject > | |
| TBuilder | Randomize () |
| Derivatives must implement this so that BuildRandom can work. | |
| Public Member Functions inherited from PeanutButter.TestUtils.AspNetCore.Builders.Builder< TBuilder, TSubject > | |
| TBuilder | With (Action< TSubject > action) |
| Adds a mutator for the artifact. | |
| virtual TSubject | Build () |
| Builds the subject artifact. | |
| Mutator (Action< T > action, string identifier) | |
Static Public Member Functions | |
| static string | DefaultJsonEncoder< T > (T value) |
| Unless otherwise specified, this will be used when encoding json, eg when creating a JSON request from an object. Under the hood, it uses System.Text.Json.JsonSerializer with default options, which may or may not suit your workload. | |
| static void | SetDefaultJsonEncoder (Func< object, string > encoder) |
| Allows setting the default JSON encoder for all HttpRequestBuilder instances. | |
| Static Public Member Functions inherited from PeanutButter.TestUtils.AspNetCore.Builders.RandomizableBuilder< TBuilder, TSubject > | |
| static TSubject | BuildRandom () |
| Builds a random variant output artifact. | |
| Static Public Member Functions inherited from PeanutButter.TestUtils.AspNetCore.Builders.Builder< TBuilder, TSubject > | |
| static TBuilder | Create () |
| Returns a new instance of the builder. | |
| static TSubject | BuildDefault () |
| Builds the default output artifact. | |
Protected Member Functions | |
| override HttpRequest | ConstructEntity () |
| Constructs the fake http request. | |
| Protected Member Functions inherited from PeanutButter.TestUtils.AspNetCore.Builders.Builder< TBuilder, TSubject > | |
| TBuilder | With (Action< TSubject > action, string identifier) |
| Adds an identified mutator for the artifact - if a mutator with the same identity already exists, it will be removed. | |
| TBuilder | With< TCast > (Action< TCast > action) |
| Adds a mutator for the artifact, cast to TCast. | |
| TBuilder | With< TCast > (Action< TCast > action, string identifier) |
| Adds an identified mutator for the artifact, cast to TCast. | |
| TBuilder | WithRandomTimes (Action< TSubject > action) |
| Applies the given mutator a random (1-4) number of times. | |
| TBuilder | WithRandomTimes< TCast > (Action< TCast > action) |
| Applies the given mutator on a cast item a random (1-4) number of times. | |
| TBuilder | WithPreCursor (Action toRun) |
| Run a precursor before your entity is constructed - use when your entity requires constructor parameters you'd like to make user-tweakable via builder methods. | |
| TBuilder | WithPostBuild (Action< TSubject > action) |
| Add post-build actions. | |
Additional Inherited Members | |
| Static Protected Member Functions inherited from PeanutButter.TestUtils.AspNetCore.Builders.Builder< TBuilder, TSubject > | |
| static void | WarnIf (bool condition, string message) |
| Print a traced warning if the condition is found to be false. | |
| static void | ErrorIf (bool condition, string message) |
| Print a traced warning if the condition is found to be false. | |
| Protected Attributes inherited from PeanutButter.TestUtils.AspNetCore.Builders.Builder< TBuilder, TSubject > | |
| TSubject | CurrentEntity |
| During build, CurrentEntity will be set to the currently-building entity. You may implement actualizer(s) in your derivative to pull this value in lazily to consumers. | |
| Properties inherited from PeanutButter.TestUtils.AspNetCore.Builders.Builder< TBuilder, TSubject > | |
| Action< T > | Action [get] |
| string | Identifier [get] |
Builds an http request.
|
protectedvirtual |
Constructs the fake http request.
Reimplemented from PeanutButter.TestUtils.AspNetCore.Builders.Builder< TBuilder, TSubject >.
|
static |
Unless otherwise specified, this will be used when encoding json, eg when creating a JSON request from an object. Under the hood, it uses System.Text.Json.JsonSerializer with default options, which may or may not suit your workload.
| value |
| T |
| override HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.Randomize | ( | ) |
Randomizes the output.
|
static |
Allows setting the default JSON encoder for all HttpRequestBuilder instances.
| encoder |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithBasePath | ( | string | basePath | ) |
Sets the base path on the request.
| basePath |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithBody | ( | byte[] | body | ) |
Sets the body for the request. If possible, form elements are derived from the body.
| body |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithBody | ( | Stream | body | ) |
Sets the body for the request. If possible, form elements are derived from the body.
| body |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithBody | ( | string | body | ) |
Sets the body for the request. If possible, form elements are derived from the body.
| body |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithContentType | ( | string | contentType | ) |
Sets the Content-Type header for the request. Note that this shouldn't be necessary most of the time - automatic content type detection is provided for requests with forms or JSON bodies.
| contentType |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithCookie | ( | string | name, |
| string | value ) |
Sets a cookie on the request. Will overwrite an existing cookie with the same name.
| name | |
| value |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithCookies | ( | IDictionary< string, string > | cookies | ) |
Sets a bunch of cookies on the request. Will overwrite existing cookies with the same name. Will not remove any other existing cookies.
| cookies |
| ArgumentNullException |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithCookies | ( | IRequestCookieCollection | cookies | ) |
Sets the cookie collection on the request.
| cookies |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithForm | ( | IFormCollection | formCollection | ) |
Sets the form on the request.
| formCollection |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithFormField | ( | string | key, |
| string | value ) |
Set a field on the form of the request.
| key | |
| value |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithFormFields | ( | IDictionary< string, string > | fields | ) |
Sets a collection of fields on the form of the request.
| fields |
| ArgumentNullException |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithFormFile | ( | byte[] | content, |
| string | name, | ||
| string | fileName ) |
Adds a form file with binary content and the provided name and filename.
| content | |
| name | |
| fileName |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithFormFile | ( | IFormFile | file | ) |
Adds a file to the form of the request.
| file |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithFormFile | ( | Stream | content, |
| string | name, | ||
| string | fileName ) |
Adds a form file with text content and the provided name and filename.
| content | |
| name | |
| fileName |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithFormFile | ( | string | content, |
| string | name, | ||
| string | fileName ) |
Adds a form file with string content and the provided name and filename.
| content | |
| name | |
| fileName |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithHeader | ( | string | header, |
| string | value ) |
Sets a header on the request. Any existing header with the same name is overwritten.
| header | |
| value |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithHeaders | ( | IDictionary< string, string > | headers | ) |
Sets a bunch of headers on the request. Existing cookies with the same names are overwritten. Other existing cookies are left intact.
| headers |
| ArgumentNullException |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithHeaders | ( | IHeaderDictionary | headers | ) |
Sets the header dictionary on the request.
| headers |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithHost | ( | HostString | host | ) |
Sets the host on the path.
| host |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithHost | ( | string | host | ) |
Sets the host on the request.
| host |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithHttpContext | ( | Func< HttpContext > | accessor | ) |
Sets the http context accessor on the request.
| accessor |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithHttpContext | ( | HttpContext | context | ) |
Sets the http context on the request.
| context |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithHttpContextMutator | ( | Action< FakeHttpContext > | mutator | ) |
Facilitates easier http context mutations.
| mutator |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithJsonBody< T > | ( | T | data | ) |
| data |
| T |
| void PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithJsonEncoder | ( | Func< object, string > | encoder | ) |
Sets up a JSON encoder to use on this instance of HttpRequestBuilder only, to be used when generating a request body as JSON from an object.
| encoder |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithMethod | ( | HttpMethod | method | ) |
Sets the method on the request.
| method |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithMethod | ( | string | method | ) |
Sets the method on the request.
| method |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithNoCookies | ( | ) |
Clears cookies on the request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithNoHeaders | ( | ) |
Clears headers on the request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithOrigin | ( | string | origin | ) |
Sets the Origin header.
| origin |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithPath | ( | string | path | ) |
| path |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithPort | ( | int | port | ) |
Sets the port on the request.
| port |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithQuery | ( | IQueryCollection | query | ) |
Sets the query collection on the request.
| query |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithQueryParameter | ( | string | key, |
| string | value ) |
Sets a query parameter on the request.
| key | |
| value |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithQueryParameters | ( | IDictionary< string, string > | parameters | ) |
Set multiple query parameters from a dictionary.
| parameters |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithQueryString | ( | QueryString | queryString | ) |
Sets the query string on the request.
| queryString |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithQueryString | ( | string | queryString | ) |
Sets the query string on the request.
| queryString |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRandomCookies | ( | ) |
Adds some random cookies to the request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRandomForm | ( | ) |
Adds a random form to the request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRandomHeaders | ( | ) |
Adds some random X- prefixed headers for the request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRandomHost | ( | ) |
Selects a random hostname for the request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRandomMethod | ( | ) |
Selects a random http method for the request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRandomPath | ( | ) |
Selects a random path for the request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRandomPort | ( | ) |
Selects a random port (80-10000) for the request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRandomScheme | ( | ) |
Selects a random scheme (http|https) for the request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRandomUrl | ( | ) |
Sets a random url for this request.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRemoteAddress | ( | IPAddress | address | ) |
Sets the HttpContext.Connection.RemoteIpAddress value.
| address |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithRemoteAddress | ( | string | ipAddress | ) |
Sets the HttpContext.Connection.RemoteIpAddress value.
| ipAddress |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithScheme | ( | string | scheme | ) |
Sets the scheme on the request.
| scheme |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithSelfOrigin | ( | ) |
Sets the origin header to be the root of the request's uri.
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithUrl | ( | string | url | ) |
Set the full url for the request.
| url |
| HttpRequestBuilder PeanutButter.TestUtils.AspNetCore.Builders.HttpRequestBuilder.WithUrl | ( | Uri | url | ) |
Set the full url for the request.
| url |