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

Builds a ModelBindingContext for testing. More...

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

Public Member Functions

override ModelBindingContextBuilder Randomize ()
 ModelBindingContextBuilder ()
ModelBindingContextBuilder WithModelValue (StringValues value)
 Convenience method to set the value for the model. Cannot be used in conjunction with a custom value provider.
ModelBindingContextBuilder WithSuccessfulModelBindingResult ()
 Sets a successful Result property from Model on the ModelBindingContext at the time the mutation is run.
ModelBindingContextBuilder WithFailedModelBindingResult ()
 Sets a failed Result property.
ModelBindingContextBuilder WithModelBindingResult (ModelBindingResult modelBindingResult)
 Sets the Result property.
ModelBindingContextBuilder WithModelBindingResult (Func< object, ModelBindingResult > modelBindingResultGenerator)
 Sets a Result by generating it from the current Model on the ModelBindingContext.
ModelBindingContextBuilder WithValueProvider (IValueProvider valueProvider)
 Resets the main ValueProvider (which defaults to a CompositeValueProvider)
ModelBindingContextBuilder WithPartialValueProvider (IValueProvider valueProvider)
 Adds a ValueProvider to the CompositeValueProvider provided by the ValueProvider property. Will reset the ValueProvider to be a CompositeValueProvider if it isn't one already.
ModelBindingContextBuilder WithValidationState (ValidationStateDictionary validationState)
 Sets the ValidationState property.
ModelBindingContextBuilder WithPropertyFilter (Func< ModelMetadata, bool > propertyFilter)
 Sets the PropertyFilter property.
ModelBindingContextBuilder WithModelState (ModelStateDictionary modelState)
 Sets the ModelState property.
ModelBindingContextBuilder WithModelMetadata (ModelMetadata modelMetadata)
 Sets the ModelMetadata property.
ModelBindingContextBuilder WithModel (object model)
 Sets the Model property.
ModelBindingContextBuilder WithFieldName (string fieldName)
 Sets the FieldName property.
ModelBindingContextBuilder WithTopLevelObject (bool isTopLevelObject)
 Sets the IsTopLevelObject property.
ModelBindingContextBuilder WithBindingSource (BindingSource bindingSource)
 Sets the BindingSource property.
ModelBindingContextBuilder WithModelName (string modelName)
 Sets the ModelName property.
ModelBindingContextBuilder WithActionContext (ActionContext ctx)
 Sets the action context for the model-binding context.
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)

Protected Member Functions

override ModelBindingContext ConstructEntity ()
 Override in a derivative builder to provide a custom implementation for TSubject.
Returns
Exceptions
CustomConstructEntityRequired

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.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.
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 ModelBindingContext for testing.

Member Function Documentation

◆ ConstructEntity()

override ModelBindingContext PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.ConstructEntity ( )
protectedvirtual

Override in a derivative builder to provide a custom implementation for TSubject.

Returns
Exceptions
CustomConstructEntityRequired

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

◆ WithActionContext()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithActionContext ( ActionContext ctx)

Sets the action context for the model-binding context.

Parameters
ctx
Returns

◆ WithBindingSource()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithBindingSource ( BindingSource bindingSource)

Sets the BindingSource property.

Parameters
bindingSource
Returns

◆ WithFailedModelBindingResult()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithFailedModelBindingResult ( )

Sets a failed Result property.

Returns

◆ WithFieldName()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithFieldName ( string fieldName)

Sets the FieldName property.

Parameters
fieldName
Returns

◆ WithModel()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithModel ( object model)

Sets the Model property.

Parameters
model
Returns

◆ WithModelBindingResult() [1/2]

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithModelBindingResult ( Func< object, ModelBindingResult > modelBindingResultGenerator)

Sets a Result by generating it from the current Model on the ModelBindingContext.

Parameters
modelBindingResultGenerator
Returns

◆ WithModelBindingResult() [2/2]

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithModelBindingResult ( ModelBindingResult modelBindingResult)

Sets the Result property.

Parameters
modelBindingResult
Returns

◆ WithModelMetadata()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithModelMetadata ( ModelMetadata modelMetadata)

Sets the ModelMetadata property.

Parameters
modelMetadata
Returns

◆ WithModelName()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithModelName ( string modelName)

Sets the ModelName property.

Parameters
modelName
Returns

◆ WithModelState()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithModelState ( ModelStateDictionary modelState)

Sets the ModelState property.

Parameters
modelState
Returns

◆ WithModelValue()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithModelValue ( StringValues value)

Convenience method to set the value for the model. Cannot be used in conjunction with a custom value provider.

Parameters
value
Returns

◆ WithPartialValueProvider()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithPartialValueProvider ( IValueProvider valueProvider)

Adds a ValueProvider to the CompositeValueProvider provided by the ValueProvider property. Will reset the ValueProvider to be a CompositeValueProvider if it isn't one already.

Parameters
valueProvider
Returns

◆ WithPropertyFilter()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithPropertyFilter ( Func< ModelMetadata, bool > propertyFilter)

Sets the PropertyFilter property.

Parameters
propertyFilter
Returns

◆ WithSuccessfulModelBindingResult()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithSuccessfulModelBindingResult ( )

Sets a successful Result property from Model on the ModelBindingContext at the time the mutation is run.

Returns

◆ WithTopLevelObject()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithTopLevelObject ( bool isTopLevelObject)

Sets the IsTopLevelObject property.

Parameters
isTopLevelObject
Returns

◆ WithValidationState()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithValidationState ( ValidationStateDictionary validationState)

Sets the ValidationState property.

Parameters
validationState
Returns

◆ WithValueProvider()

ModelBindingContextBuilder PeanutButter.TestUtils.AspNetCore.Builders.ModelBindingContextBuilder.WithValueProvider ( IValueProvider valueProvider)

Resets the main ValueProvider (which defaults to a CompositeValueProvider)

Parameters
valueProvider
Returns

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