Show / Hide Table of Contents

Class MockCreationResult<T>

The result of the creation of an instance of a class with Moq-based mocks.

Inheritance
object
MockCreationResult<T>
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
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 Source

MockCreationResult(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 Source

ConstructorArguments

Declaration
protected object[]? ConstructorArguments { get; }
Property Value
Type Description
object[]
| Edit this page View Source

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
| Edit this page View Source

IsInstanceCreated

Declaration
public bool IsInstanceCreated { get; }
Property Value
Type Description
bool
| Edit this page View Source

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>
| Edit this page View Source

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 Source

GetMock<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

| Edit this page View Source

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

Extension Methods

ObjectAssertExtensions.ShouldBeNull<T>(T?, string)
ObjectAssertExtensions.ShouldBeSameAs<T>(T, T, string)
ObjectAssertExtensions.ShouldEqual<T>(T, T, string)
ObjectAssertExtensions.ShouldNotBeNull<T>(T?, string)
ObjectAssertExtensions.ShouldNotBeSameAs<T>(T, T, string)
ObjectAssertExtensions.ShouldNotEqual<T>(T, T, string)
ObjectAssertExtensions.ShouldBeOfType<T>(object?, string)
ObjectAssertExtensions.ShouldNotBeOfType<T>(object?, string)
  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com