MiniMock

Minimalistic approach to mocking in .NET

View on GitHub

Decision on Supporting Properties

Context

In the MiniMock framework, there is a need to determine the scope of support for mocking properties. Properties are a fundamental part of C# classes and interfaces, and supporting them is essential for a comprehensive mocking framework.

Decision

The MiniMock framework will support mocking both read-only and read-write properties. This includes properties in classes and interfaces, ensuring that the framework can handle a wide range of scenarios.

Properties must be mockable using the following parameters:

Get-only and set-only properties must only allow mocking of the corresponding getter or setter.

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

Consequences

Positive:

Negative:

This decision ensures that the MiniMock framework supports a wide range of property types, providing flexibility and comprehensive mocking capabilities.


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