PeanutButter
Loading...
Searching...
No Matches
PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder Class Reference

Builds a controller context. More...

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

Public Member Functions

 ControllerContextBuilder ()
ControllerContextBuilder WithRouteDataValue (string key, string value)
 Sets a RouteData value (eg "controller", "action", etc)
ControllerContextBuilder WithRouteData (RouteData routeData)
 Sets the RouteData on the context.
ControllerContextBuilder WithHttpContext (HttpContext context)
 Sets the http context for the controller.
ControllerContextBuilder WithRequest (HttpRequest request)
 Sets the request on the http context for the controller (if possible)
ControllerContextBuilder WithResponse (HttpResponse response)
 Sets the response on the http context for the controller (if possible)
ControllerContextBuilder WithActionDescriptor (ControllerActionDescriptor descriptor)
 Sets the ControllerActionDescriptor on the context.
ControllerContextBuilder WithControllerType (Type type)
 Sets the controller type on the action descriptor (as well as taking a guess at the name)
ControllerContextBuilder WithIdentity (IIdentity identity)
 Add the identity to the available claims identities.
ControllerContextBuilder WithUser (ClaimsPrincipal user)
 Sets the User on the HttpContext of the ControllerContext.
ControllerContextBuilder WithHttpContextMutator (Action< FakeHttpContext > mutator)
 Facilitates easier http context mutations.
ControllerContextBuilder WithController< T > (T controller)
 Associates the context with the provided controller.
ControllerContextBuilder WithRequestHeader (string header, string value)
 Set a request header on the associated http context.
ControllerContextBuilder WithAction (string name)
 Sets the action on the context.
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)

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.
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.
virtual TSubject ConstructEntity ()
 Override in a derivative builder to provide a custom implementation for TSubject.
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.
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 a controller context.

Member Function Documentation

◆ WithAction()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithAction ( string name)

Sets the action on the context.

Parameters
name
Returns

◆ WithActionDescriptor()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithActionDescriptor ( ControllerActionDescriptor descriptor)

Sets the ControllerActionDescriptor on the context.

Parameters
descriptor
Returns

◆ WithController< T >()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithController< T > ( T controller)

Associates the context with the provided controller.

Parameters
controller
Template Parameters
T
Returns
Type Constraints
T :ControllerBase 

◆ WithControllerType()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithControllerType ( Type type)

Sets the controller type on the action descriptor (as well as taking a guess at the name)

Parameters
type
Returns

◆ WithHttpContext()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithHttpContext ( HttpContext context)

Sets the http context for the controller.

Parameters
context
Returns

◆ WithHttpContextMutator()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithHttpContextMutator ( Action< FakeHttpContext > mutator)

Facilitates easier http context mutations.

Parameters
mutator
Returns

◆ WithIdentity()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithIdentity ( IIdentity identity)

Add the identity to the available claims identities.

  • the original ClaimsPrincipal should be empty
Parameters
identity
Returns

◆ WithRequest()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithRequest ( HttpRequest request)

Sets the request on the http context for the controller (if possible)

Parameters
request
Returns

◆ WithRequestHeader()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithRequestHeader ( string header,
string value )

Set a request header on the associated http context.

Parameters
header
value
Returns

◆ WithResponse()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithResponse ( HttpResponse response)

Sets the response on the http context for the controller (if possible)

Parameters
response
Returns

◆ WithRouteData()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithRouteData ( RouteData routeData)

Sets the RouteData on the context.

Parameters
routeData
Returns

◆ WithRouteDataValue()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithRouteDataValue ( string key,
string value )

Sets a RouteData value (eg "controller", "action", etc)

Parameters
key
value
Returns

◆ WithUser()

ControllerContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ControllerContextBuilder.WithUser ( ClaimsPrincipal user)

Sets the User on the HttpContext of the ControllerContext.

Parameters
user
Returns

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