MiniMock

Minimalistic approach to mocking in .NET

View on GitHub

Decision on Supporting Methods

Context

In the MiniMock framework, there is a need to determine the scope of support for mocking methods. Supporting all standard ways of creating methods is essential to ensure the framework’s flexibility and usability.

The following type of methods must be supported

Decision

The MiniMock framework will support all standard ways of creating methods. This includes instance methods, static methods, virtual methods, and abstract methods. However, support for methods returning ref values will require additional work and will be addressed in future updates. See issue #5

Methods must be mockable using the following parameters

if none of the above parameters are provided, calling the method must throw a InvalidOperationException with a message in the form “The method ‘[method name]’ in ‘[mocked class]’ is not explicitly mocked.”.

Asynchronous methods are supported. Helper methods are provided to simplify the testing of asynchronous methods. Overloads of the following helper methods are added

Overloaded methods can either be mocked explicitly by using Call or collectively using the following

Generic methods are supported. The generic type is passed as a type parameter to the ‘call’ labmda method.

Consequences

Positive:

Negative:


More ADRs can be found in the docs/ADR directory.