PeanutButter
Loading...
Searching...
No Matches
PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController > Class Template Reference

Builds your. More...

Inheritance diagram for PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >:
PeanutButter.TestUtils.AspNetCore.Builders.Builder< TBuilder, TSubject >

Public Member Functions

 ControllerBuilder ()
ControllerBuilder< TController > WithTempDataProvider (Func< ITempDataProvider > func)
 Set up a factory for a TempDataProvider.
ControllerBuilder< TController > WithFactory (Func< TController > factory)
 Provide a factory to create the controller. If your controller has constructor parameters, this is how you'd inject them.
ControllerBuilder< TController > WithRequestQueryParameter (string parameter, string value)
 Set a query parameter on the request object NB: this will not automatically map to method parameters on your actions, so you only need to set these if you're interrogating the raw query or want to update the overall querystring.
ControllerBuilder< TController > WithRequestHost (string host)
 Sets the hostname for the request.
ControllerBuilder< TController > WithRequestPort (int port)
 Sets the port for the request.
ControllerBuilder< TController > WithRequestHost (HostString host)
 Sets the host for the request.
ControllerBuilder< TController > WithRequestScheme (string scheme)
 Sets the scheme for the request.
ControllerBuilder< TController > WithRequestQueryParameter (string parameter, StringValues value)
 Sets a query parameter on the request for the controller.
ControllerBuilder< TController > WithHttpContextItem (string key, object value)
 Sets an item on the http context for the controller.
ControllerBuilder< TController > WithRequestCookie (string key, string value)
 Sets a cookie value on the request for the controller.
ControllerBuilder< TController > WithRequestCookies (IDictionary< string, string > cookies)
 Sets a bunch of cookies on the request for the controller.
ControllerBuilder< TController > WithRequestHeader (string header, string value)
 Sets a header on the request for the controller.
ControllerBuilder< TController > WithControllerContext (ControllerContext ctx)
 Sets the controller context for your controller.
ControllerBuilder< TController > WithActionDescriptor (ControllerActionDescriptor actionDescriptor)
 Sets the action descriptor for your controller.
ControllerBuilder< TController > WithRouteData (RouteData data)
 Sets the route data for your controller.
ControllerBuilder< TController > WithRouteDataValue (string key, object value)
 Sets some route data value.
ControllerBuilder< TController > WithHttpContext (HttpContext context)
 Sets the http context for your controller.
ControllerBuilder< TController > WithOptions (IOptions< MvcOptions > options)
 Set the options for the controller.
ControllerBuilder< TController > WithOptions (Func< IOptions< MvcOptions > > factory)
 Set the options for the controller (late-resolved singleton)
ControllerBuilder< TController > WithTempDataDictionaryFactory (ITempDataDictionaryFactory tempDataDictionaryFactory)
 Set the temp data dictionary factory for the controller.
ControllerBuilder< TController > WithTempDataDictionaryFactory (Func< ITempDataDictionaryFactory > factoryFactory)
 Set the temp data dictionary factory for the controller (late-resolved singleton)
ControllerBuilder< TController > WithModelValidator (IObjectModelValidator validator)
 Set the model validator.
ControllerBuilder< TController > WithModelValidator (Func< IObjectModelValidator > factory)
 Set the model validator (late-resolved singleton)
ControllerBuilder< TController > WithModelMetadataProvider (Func< IModelMetadataProvider > modelMetadataProvider)
 Set the model metadata provider.
ControllerBuilder< TController > WithModelMetadataProvider (IModelMetadataProvider modelMetadataProvider)
 Set the model metadata provider (late-bound singleton)
ControllerBuilder< TController > WithActionContext (Func< ControllerContext, ActionContext > factory)
 Set the action context (will be automatically called when you set the http context). This variant will have access to the controller so it can access any property of said controller.
ControllerBuilder< TController > WithActionContext (ActionContext actionContext)
 Set the action context (late-bound singleton)
ControllerBuilder< TController > WithAction (string name)
 Sets the action on the controller descriptor. If the action can be found on the controller, the controller descriptor's method info will also be set.
ControllerBuilder< TController > WithRequestUrl (string url)
 Sets the url on the associated request. Does NOT set any routing parameters (eg action)
ControllerBuilder< TController > WithRequestUrl (Uri url)
 Sets the url on the associated request. Does NOT set any routing parameters (eg action)
ControllerBuilder< TController > WithRequestMutator (Action< FakeHttpRequest > mutator)
 Facilitates arbitrary mutations on the existing FakeHttpRequest for this build.
ControllerBuilder< TController > WithRequestHeaders (IDictionary< string, string > headers)
 Set multiple request headers at once.
ControllerBuilder< TController > WithRequestMethod (string method)
 Set the request method for the associated request.
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)

Protected Member Functions

override TController ConstructEntity ()
 Constructs the controller, either using a provided factory or with the assumption that the controller has a parameterless constructor.
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 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.
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]

Detailed Description

Builds your.

Template Parameters
TController
Type Constraints
TController :ControllerBase 

Member Function Documentation

◆ ConstructEntity()

override TController PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.ConstructEntity ( )
protectedvirtual

Constructs the controller, either using a provided factory or with the assumption that the controller has a parameterless constructor.

Returns

Reimplemented from PeanutButter.TestUtils.AspNetCore.Builders.Builder< TBuilder, TSubject >.

◆ WithAction()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithAction ( string name)

Sets the action on the controller descriptor. If the action can be found on the controller, the controller descriptor's method info will also be set.

Parameters
name
Returns

◆ WithActionContext() [1/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithActionContext ( ActionContext actionContext)

Set the action context (late-bound singleton)

Parameters
actionContext
Returns

◆ WithActionContext() [2/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithActionContext ( Func< ControllerContext, ActionContext > factory)

Set the action context (will be automatically called when you set the http context). This variant will have access to the controller so it can access any property of said controller.

Parameters
factory
Returns

◆ WithActionDescriptor()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithActionDescriptor ( ControllerActionDescriptor actionDescriptor)

Sets the action descriptor for your controller.

Parameters
actionDescriptor
Returns

◆ WithControllerContext()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithControllerContext ( ControllerContext ctx)

Sets the controller context for your controller.

Parameters
ctx
Returns

◆ WithFactory()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithFactory ( Func< TController > factory)

Provide a factory to create the controller. If your controller has constructor parameters, this is how you'd inject them.

Parameters
factory
Returns

◆ WithHttpContext()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithHttpContext ( HttpContext context)

Sets the http context for your controller.

Parameters
context
Returns

◆ WithHttpContextItem()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithHttpContextItem ( string key,
object value )

Sets an item on the http context for the controller.

Parameters
key
value
Returns

◆ WithModelMetadataProvider() [1/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithModelMetadataProvider ( Func< IModelMetadataProvider > modelMetadataProvider)

Set the model metadata provider.

Parameters
modelMetadataProvider
Returns

◆ WithModelMetadataProvider() [2/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithModelMetadataProvider ( IModelMetadataProvider modelMetadataProvider)

Set the model metadata provider (late-bound singleton)

Parameters
modelMetadataProvider
Returns

◆ WithModelValidator() [1/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithModelValidator ( Func< IObjectModelValidator > factory)

Set the model validator (late-resolved singleton)

Parameters
factory
Returns

◆ WithModelValidator() [2/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithModelValidator ( IObjectModelValidator validator)

Set the model validator.

Parameters
validator
Returns

◆ WithOptions() [1/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithOptions ( Func< IOptions< MvcOptions > > factory)

Set the options for the controller (late-resolved singleton)

Parameters
factory
Returns

◆ WithOptions() [2/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithOptions ( IOptions< MvcOptions > options)

Set the options for the controller.

Parameters
options
Returns

◆ WithRequestCookie()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestCookie ( string key,
string value )

Sets a cookie value on the request for the controller.

Parameters
key
value
Returns

◆ WithRequestCookies()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestCookies ( IDictionary< string, string > cookies)

Sets a bunch of cookies on the request for the controller.

Parameters
cookies
Returns
Exceptions
InvalidOperationException

◆ WithRequestHeader()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestHeader ( string header,
string value )

Sets a header on the request for the controller.

Parameters
header
value
Returns

◆ WithRequestHeaders()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestHeaders ( IDictionary< string, string > headers)

Set multiple request headers at once.

Parameters
headers
Returns

◆ WithRequestHost() [1/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestHost ( HostString host)

Sets the host for the request.

Parameters
host
Returns

◆ WithRequestHost() [2/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestHost ( string host)

Sets the hostname for the request.

Parameters
host
Returns

◆ WithRequestMethod()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestMethod ( string method)

Set the request method for the associated request.

Parameters
method
Returns

◆ WithRequestMutator()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestMutator ( Action< FakeHttpRequest > mutator)

Facilitates arbitrary mutations on the existing FakeHttpRequest for this build.

Parameters
mutator
Returns

◆ WithRequestPort()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestPort ( int port)

Sets the port for the request.

Parameters
port
Returns

◆ WithRequestQueryParameter() [1/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestQueryParameter ( string parameter,
string value )

Set a query parameter on the request object NB: this will not automatically map to method parameters on your actions, so you only need to set these if you're interrogating the raw query or want to update the overall querystring.

Parameters
parameter
value
Returns

◆ WithRequestQueryParameter() [2/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestQueryParameter ( string parameter,
StringValues value )

Sets a query parameter on the request for the controller.

Parameters
parameter
value
Returns

◆ WithRequestScheme()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestScheme ( string scheme)

Sets the scheme for the request.

Parameters
scheme
Returns

◆ WithRequestUrl() [1/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestUrl ( string url)

Sets the url on the associated request. Does NOT set any routing parameters (eg action)

Parameters
url
Returns

◆ WithRequestUrl() [2/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRequestUrl ( Uri url)

Sets the url on the associated request. Does NOT set any routing parameters (eg action)

Parameters
url
Returns

◆ WithRouteData()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRouteData ( RouteData data)

Sets the route data for your controller.

Parameters
data
Returns

◆ WithRouteDataValue()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithRouteDataValue ( string key,
object value )

Sets some route data value.

Parameters
key
value
Returns

◆ WithTempDataDictionaryFactory() [1/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithTempDataDictionaryFactory ( Func< ITempDataDictionaryFactory > factoryFactory)

Set the temp data dictionary factory for the controller (late-resolved singleton)

Parameters
factoryFactory
Returns

◆ WithTempDataDictionaryFactory() [2/2]

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithTempDataDictionaryFactory ( ITempDataDictionaryFactory tempDataDictionaryFactory)

Set the temp data dictionary factory for the controller.

Parameters
tempDataDictionaryFactory
Returns

◆ WithTempDataProvider()

ControllerBuilder< TController > PeanutButter.TestUtils.AspNetCore.Builders.ControllerBuilder< TController >.WithTempDataProvider ( Func< ITempDataProvider > func)

Set up a factory for a TempDataProvider.

Parameters
func
Returns
Exceptions
NotImplementedException

The documentation for this class was generated from the following file:
  • source/TestUtils/PeanutButter.TestUtils.AspNetCore/Builders/ControllerBuilder.cs