PeanutButter
Loading...
Searching...
No Matches
PeanutButter.RandomGenerators.GenericBuilderBase Class Referenceabstract

Abstract base class for housing shared logic between all builders and allowing a base, unconstructable class to use to reference a collection of builders. More...

Inheritance diagram for PeanutButter.RandomGenerators.GenericBuilderBase:
PeanutButter.RandomGenerators.GenericBuilder< TBuilder, TEntity > PeanutButter.TestUtils.Async.ImmediateTaskRunnerBuilder

Static Public Member Functions

static bool TryCreateSubstituteFor< T > (bool callThrough, out T result)
 Attempt to create a substitute for the given type.
static bool TryCreateSubstituteFor< T > (bool callThrough, object[] constructorParameters, out T result)
 Attempt to create a substitute for the given type with parameters.
static bool TryCreateSubstituteFor< T > (bool throwOnError, bool callThrough, out T result)
 Attempt to create a substitute from a type with a parameterless constructor.
static bool TryCreateSubstituteFor< T > (bool throwOnError, bool callThrough, object[] constructorParameters, out T result)
 Attempts perform Substitute.For<T>.

Static Public Attributes

const string ENV_FORCE_NSUBSTITUTE_FOR_RANDOMVALUEGEN = "FORCE_NSUBSTITUTE_FOR_RANDOMVALUEGEN"
 The environment variable which is observed to force using NSubstitute for random value generation of interface types.

Static Protected Member Functions

static Assembly FindOrLoadAssembly< T > (string name, bool retrying)
 Attempts to load the assembly alongside the Type T.

Static Protected Attributes

static readonly Dictionary< Type, Type > DynamicBuilders = new Dictionary<Type, Type>()
 Holds a lookup of all GenericBuilder classes which have been generated to facilitate automatic property building. Searched when looking for a builder to generate a property before attempting to generate a builder type (re-use)
static readonly Dictionary< Type, Type > UserBuilders = new Dictionary<Type, Type>()
 Holds a lookup of GenericBuilder classes which were provided by consuming code. Searched before searching the DynamicBuilders lookup or attempting to create an auto-generated builder type.
static readonly Type NullableGeneric = typeof(Nullable<>)
 Provides a lookup to the type which is the generic Nulllable.
static readonly Type GenericBuilderBaseType = typeof(GenericBuilderBase)
 Provides a lookup to the type which is the GenericBuilder.

Properties

static int MaxRandomPropsLevel = 10 [get, set]
 Sets the maximum level to go to when generating random properties of random properties, to prevent stack and memory overflows.

Detailed Description

Abstract base class for housing shared logic between all builders and allowing a base, unconstructable class to use to reference a collection of builders.

Member Function Documentation

◆ FindOrLoadAssembly< T >()

Assembly PeanutButter.RandomGenerators.GenericBuilderBase.FindOrLoadAssembly< T > ( string name,
bool retrying )
staticprotected

Attempts to load the assembly alongside the Type T.

Parameters
name
retrying
Template Parameters
T
Returns

◆ TryCreateSubstituteFor< T >() [1/4]

bool PeanutButter.RandomGenerators.GenericBuilderBase.TryCreateSubstituteFor< T > ( bool callThrough,
object[] constructorParameters,
out T result )
static

Attempt to create a substitute for the given type with parameters.

Parameters
callThroughCreate a partial sub where calls go through to the original implementation
constructorParameters
result
Template Parameters
T
Returns

◆ TryCreateSubstituteFor< T >() [2/4]

bool PeanutButter.RandomGenerators.GenericBuilderBase.TryCreateSubstituteFor< T > ( bool callThrough,
out T result )
static

Attempt to create a substitute for the given type.

Parameters
callThroughCreate a partial sub where calls go through to the original implementation
result
Template Parameters
T
Returns

◆ TryCreateSubstituteFor< T >() [3/4]

bool PeanutButter.RandomGenerators.GenericBuilderBase.TryCreateSubstituteFor< T > ( bool throwOnError,
bool callThrough,
object[] constructorParameters,
out T result )
static

Attempts perform Substitute.For<T>.

Template Parameters
T
Returns
Exceptions
Exception

◆ TryCreateSubstituteFor< T >() [4/4]

bool PeanutButter.RandomGenerators.GenericBuilderBase.TryCreateSubstituteFor< T > ( bool throwOnError,
bool callThrough,
out T result )
static

Attempt to create a substitute from a type with a parameterless constructor.

Parameters
throwOnError
callThrough
result
Template Parameters
T
Returns

The documentation for this class was generated from the following file:
  • source/TestUtils/PeanutButter.RandomGenerators/GenericBuilderBase.cs