Show / Hide Table of Contents

Class MockUtility

This class is used to create instances of classes using reflection and Moq.

Inheritance
object
MockUtility
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 static class MockUtility

Methods

| Edit this page View Source

CreateInstance<T>()

Creates an instance of a class using reflection and Moq. If the class has a parameterless constructor, it will be used. If the class has a constructor with parameters, mocks will be created for each parameter type. ///

Declaration
public static MockCreationResult<T> CreateInstance<T>() where T : class
Returns
Type Description
MockCreationResult<T>

MockCreationResult that provides access to the instance of T that was instantiated and also access to the Moq mocks.

Type Parameters
Name Description
T

Create an instance of this type. This is typically the system under test.

Exceptions
Type Condition
InvalidOperationException

Exceptions are thrown if the class does not have any constructors or has multiple constructors. BTW, if you have suggestions on how to gracefully handle the multi-constructor case, please let me know.

  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com