Class MockUtility
This class is used to create instances of classes using reflection and Moq.
Inherited Members
Namespace: Benday.Common.Testing
Assembly: Benday.Common.Testing.dll
Syntax
public static class MockUtility
Methods
| Edit this page View SourceCreateInstance<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. |