AutoMocker.CreateInstance method (1 of 4)

April 20, 2021 · View on GitHub

Constructs an instance from known services. Any dependencies (constructor arguments) are fulfilled by searching the container or, if not found, automatically generating mocks.

public object CreateInstance(Type type)
parameterdescription
typeA concrete type

Return Value

An instance of type with all constructor arguments derived from services setup in the container.

See Also


AutoMocker.CreateInstance method (2 of 4)

Constructs an instance from known services. Any dependencies (constructor arguments) are fulfilled by searching the container or, if not found, automatically generating mocks.

public object CreateInstance(Type type, bool enablePrivate)
parameterdescription
typeA concrete type
enablePrivateWhen true, non-public constructors will also be used to create mocks.

Return Value

An instance of type with all constructor arguments derived from services setup in the container.

See Also


AutoMocker.CreateInstance<T> method (3 of 4)

Constructs an instance from known services. Any dependencies (constructor arguments) are fulfilled by searching the container or, if not found, automatically generating mocks.

public T CreateInstance<T>()
    where T : class
parameterdescription
TA concrete type

Return Value

An instance of T with all constructor arguments derived from services setup in the container.

See Also


AutoMocker.CreateInstance<T> method (4 of 4)

Constructs an instance from known services. Any dependencies (constructor arguments) are fulfilled by searching the container or, if not found, automatically generating mocks.

public T CreateInstance<T>(bool enablePrivate)
    where T : class
parameterdescription
TA concrete type
enablePrivateWhen true, non-public constructors will also be used to create mocks.

Return Value

An instance of T with all constructor arguments derived from services setup in the container.

See Also