Class MockCreationResult<T>
The result of the creation of an instance of a class with Moq-based mocks.
Inherited Members
Namespace: Benday.Common.Testing
Assembly: Benday.Common.Testing.dll
Syntax
public class MockCreationResult<T> where T : class
Type Parameters
| Name | Description |
|---|---|
| T | The type for the class that was created |
Constructors
| Edit this page View SourceMockCreationResult(ConstructorInfo, object[]?, Dictionary<Type, Mock>)
Declaration
public MockCreationResult(ConstructorInfo reflectedConstructor, object[]? constructorArguments, Dictionary<Type, Mock> mocks)
Parameters
| Type | Name | Description |
|---|---|---|
| ConstructorInfo | reflectedConstructor | |
| object[] | constructorArguments | |
| Dictionary<Type, Mock> | mocks |
Properties
| Edit this page View SourceConstructorArguments
Declaration
protected object[]? ConstructorArguments { get; }
Property Value
| Type | Description |
|---|---|
| object[] |
Instance
The instance of the desired class. This is typically the system under test. NOTE: This instance is lazy-created at the first access of the Instance property so that mocks can be configured before the object creation.
Declaration
public T Instance { get; }
Property Value
| Type | Description |
|---|---|
| T |
IsInstanceCreated
Declaration
public bool IsInstanceCreated { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Mocks
The mocks that were created for the class. This is typically the dependencies of the system under test.
Declaration
public Dictionary<Type, Mock> Mocks { get; set; }
Property Value
| Type | Description |
|---|---|
| Dictionary<Type, Mock> |
ReflectedConstructor
The reflected constructor that was used to create the instance.
Declaration
protected ConstructorInfo ReflectedConstructor { get; }
Property Value
| Type | Description |
|---|---|
| ConstructorInfo |
Methods
| Edit this page View SourceGetMock<TMock>()
Get a mock of the specified type. If not found, null is returned.
Declaration
public Mock<TMock>? GetMock<TMock>() where TMock : class
Returns
| Type | Description |
|---|---|
| Mock<TMock> | The Moq-based mock instance |
Type Parameters
| Name | Description |
|---|---|
| TMock | The type that was mocked |
GetRequiredMock<TMock>()
Get a mock of the specified type and throw an exception if it is not found.
Declaration
public Mock<TMock> GetRequiredMock<TMock>() where TMock : class
Returns
| Type | Description |
|---|---|
| Mock<TMock> | The mocked dependency |
Type Parameters
| Name | Description |
|---|---|
| TMock | The type that was mocked |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Throws an exception if not found |