Skip to content

Commit 218a92b

Browse files
authored
Feature/update documentation (#29)
* Created doc folder * For rename to lower case step 1 * Step 2 * Configure the layout * Update written documentation * Documenting the ADR work that has been done * Adding backlinks * Moving documentation around to limit folder clutter * Adding more guides * Try to add stylesheet * Try again * One more for the road * Remove troll logo * Rename css * Try again * Retry the default.html way * Adding links and making the header smaller * Adding a few more ADR containers * Fixed broken link Added documentation about construction, indexers and events * Fix minor issues with documentation * Cleaning up documentation * Fix broken images * Fix broken images * Fix casing on images * Minor updates * Trim down of files
1 parent 824f9c4 commit 218a92b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1335
-162
lines changed

README.md

Lines changed: 163 additions & 162 deletions
Large diffs are not rendered by default.

docs/ADR/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Architecture Decision Records (ADR)
2+
3+
Architecture Decision Records (ADRs) are documents that capture important architectural decisions made during the development of a MiniMock.
4+
5+
All the ADRs have been approved and are considered final decisions for the project.
6+
7+
## General ADRs [TL;DR](general/TLDR.md)
8+
9+
- [Do We __Really__ Need a New Mocking Framework?](general/DoWeNeedANewMockingFramework.md) - Deciding whether to build a new mocking framework.
10+
- [Matching Target API in Mock API](general/MatchingTargetApi.md) - Ensures the mock API closely mirrors the target API.
11+
- [How Strict Should MiniMock Be?](general/HowStrictShouldMiniMockBe.md) - Deciding how strict the framework should be.
12+
- [No Built-in Assertion Feature](general/NoBuiltInAssertionFeature.md) - Users choose their preferred assertion framework.
13+
- [No Dependencies to Shared Libraries](general/NoDependencies.md) - Avoid dependencies on shared libraries.
14+
- [Documentation and Examples](general/DocumentationAndExamples.md) - Approach to documentation and examples for the framework.
15+
- [Logging and Debugging](general/LoggingAndDebugging.md) - Approach to logging and debugging within the framework.
16+
17+
## Feature Specific ADRs [TL;DR](feature/TLDR.md)
18+
19+
- [Support for Classes and Interfaces](feature/SupportForClassesAndInterfaces.md) - How should classes and interfaces be supported.
20+
- [Support for Constructors](feature/SupportForConstructors.md) - Decision on supporting constructors in the mocking framework.
21+
- [Creating Mocks](feature/CreatingMocks.md) - Decision on how to create mocks in the framework.
22+
- [Support for Methods](feature/SupportForMethods.md) - Decision on supporting methods in the mocking framework.
23+
- [Support for Properties](feature/SupportForProperties.md) - Decision on supporting properties in the mocking framework.
24+
- [Support for Events](feature/SupportForEvents.md) - Decision on supporting events in the mocking framework.
25+
- [Support for Indexers](feature/SupportForIndexers.md) - Decision on supporting indexers in the mocking framework.
26+
27+
## Unsupported Features
28+
29+
- [Unsupported Features](Unsupported/UnsupportedFeatures.md) - Decision on which features not to support.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Unsupported features
2+
3+
## Context
4+
5+
In order to keep true to how mocking works some features will not be supported.
6+
7+
## Decision
8+
9+
**Extension methods** are not supported due to their nature. Extension methods are static methods that are called as if they were instance methods of the extended type.
10+
11+
**Sealed classes** are not supported since they can not be inherited from and such do not fit how the framework works.
12+
13+
**Static members** and **Static classes** are not supported due to the way the framework works.
14+
15+
## Consequences
16+
17+
### Positive:
18+
19+
- **No need for magic**: Mocking these features would require breaking the standard supported functionality.
20+
21+
### Negative:
22+
23+
- **No magic**: Some functionality can be harder to test but if you need to test this maby you have some other issues.

docs/ADR/feature/CreatingMocks.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Decision on How to Create Mocks
2+
3+
## Context
4+
5+
In the MiniMock framework, there is a need to establish a standardized approach for creating mocks. A consistent and efficient method for creating mocks will enhance the usability and maintainability of the framework.
6+
7+
## Decision
8+
9+
Mocks will be created using a mock factory. The mock factory will provide a centralized and consistent way to create and configure mocks, ensuring that all mocks are created following the same process and standards.
10+
The constructors of the mock object will remain accessible but should only be used for limited purposes.
11+
12+
## Consequences
13+
14+
### Positive:
15+
16+
- **Consistency**: Ensures that all mocks are created in a consistent manner.
17+
- **Centralization**: Provides a single point of control for mock creation, making it easier to manage and update.
18+
- **Ease of Use**: Simplifies the process of creating mocks for developers.
19+
20+
### Negative:
21+
22+
- **Complexity**: Introduces an additional layer of abstraction, which may add some complexity to the framework.
23+
- **Maintenance**: Requires ongoing maintenance to ensure the mock factory remains up-to-date with any changes to the framework.
24+
25+
---
26+
27+
More ADRs can be found in the [docs/ADR](../README.md) directory.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Decision on Supporting Classes and Interfaces
2+
3+
## Context
4+
5+
In the MiniMock framework, there is a need to determine the scope of support for mocking different types of members.
6+
While interfaces are the primary focus due to their flexibility and common usage in dependency injection, there is also a need to support classes to cover a broader range of use cases.
7+
8+
## Decision
9+
10+
The MiniMock framework will primarily focus on supporting interfaces but will also include support for classes.
11+
This approach ensures that the framework can be used in a wide variety of scenarios, providing flexibility and comprehensive mocking capabilities.
12+
13+
## Consequences
14+
15+
### Positive:
16+
17+
- **Flexibility**: Supports a wide range of use cases by allowing both interfaces and classes to be mocked.
18+
- **Comprehensive**: Provides a robust mocking solution that can handle various types of dependencies.
19+
- **Usability**: Makes the framework more versatile and useful for developers.
20+
21+
### Negative:
22+
23+
- **Complexity**: Adding support for classes may introduce additional complexity in the framework.
24+
- **Maintenance**: Requires ongoing maintenance to ensure both interfaces and classes are supported effectively.
25+
26+
---
27+
28+
More ADRs can be found in the [docs/ADR](../README.md) directory.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Decision on Supporting Constructors
2+
3+
## Context
4+
5+
In the MiniMock framework, there is a need to determine the scope of support for mocking constructors.
6+
7+
## Decision
8+
9+
All constructors with the supported access level should be accessible. If no constructor exists, a parameterless constructor is created.
10+
A factory for each option should be created.
11+
12+
If only internal or private constructors exist, the class is not generated and a warning is registered.
13+
14+
Additionally, the framework should support the following:
15+
16+
- **Parameterized Constructors**: Allow mocking of constructors with parameters, providing flexibility for more complex scenarios.
17+
- **Constructor Overloads**: Support multiple constructors with different parameter lists.
18+
- **Dependency Injection**: Enable mocking of constructors that use dependency injection, ensuring compatibility with modern design patterns.
19+
20+
## Consequences
21+
22+
### Positive:
23+
24+
- **Simplicity**: Simplifies the initial implementation by focusing on parameterless constructors.
25+
- **Flexibility**: Supporting parameterized constructors and overloads provides more flexibility for developers.
26+
- **Compatibility**: Ensures compatibility with dependency injection, making the framework more versatile.
27+
28+
### Negative:
29+
30+
- **Complexity**: Adding support for parameterized constructors and overloads increases the complexity of the framework.
31+
- **Maintenance**: Requires ongoing maintenance to ensure that constructor mocking remains robust and up-to-date.
32+
33+
---
34+
35+
More ADRs can be found in the [docs/ADR](../README.md) directory.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Support for Delegates (WIP)
2+
3+
Work in progress.

docs/ADR/feature/SupportForEvents.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Decision on Supporting Events
2+
3+
## Context
4+
5+
In the MiniMock framework, there is a need to determine the scope of support for mocking events. Events are a crucial part of the C# language, enabling the publisher-subscriber pattern. Supporting all types of events is essential to ensure the framework's flexibility and usability.
6+
7+
## Decision
8+
9+
The MiniMock framework will support mocking all types of events. This includes standard events, custom events, and events with different delegate types. This decision ensures that the framework can handle a wide range of scenarios involving event handling.
10+
11+
Events must be mockable using the following parameters:
12+
13+
- Raise : A method to raise the event, triggering all subscribed handlers.
14+
- Trigger : A delegate as a out parameter to be used to trigger the event.
15+
- Add/Remove : Delegates matching the event's add and remove signatures with functionality to be executed.
16+
17+
## Consequences
18+
19+
### Positive:
20+
21+
- **Comprehensive**: Ensures that the framework can handle all types of events, providing flexibility and comprehensive mocking capabilities.
22+
- **Usability**: Enhances the framework's usability by allowing developers to mock events in various scenarios.
23+
24+
### Negative:
25+
26+
- **Complexity**: Supporting all types of events adds complexity to the framework.
27+
- **Maintenance**: Requires ongoing maintenance to ensure that event mocking remains robust and up-to-date.
28+
29+
---
30+
31+
More ADRs can be found in the [docs/ADR](../README.md) directory.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Decision on Supporting Indexers
2+
3+
## Context
4+
5+
In the MiniMock framework, there is a need to determine the scope of support for mocking indexers. Indexers allow objects to be indexed in a similar way to arrays, and supporting them is essential for a comprehensive mocking framework.
6+
7+
## Decision
8+
9+
The MiniMock framework will support mocking indexers. This includes both read-only and read-write indexers, ensuring that the framework can handle a wide range of scenarios.
10+
11+
Indexers must be mockable using the following parameters:
12+
13+
- Get/Set : Delegates matching the indexer's getter and setter signature with functionality to be executed.
14+
- Values : A dictionary optionally containing values to be used as the indexers source.
15+
16+
if none of the above parameters are provided, accessing the indexer must throw a InvalidOperationException with a message in the form "The indexer for '__[indexer type]__' in '__[mocked class]__' is not explicitly mocked.".
17+
18+
## Consequences
19+
20+
### Positive:
21+
22+
- **Comprehensive**: Ensures that the framework can handle indexers in both classes and interfaces.
23+
- **Flexibility**: Provides developers with the ability to mock different kinds of indexers, enhancing the framework's usability.
24+
25+
### Negative:
26+
27+
- **Complexity**: Supporting both read-only and read-write indexers adds complexity to the framework.
28+
- **Maintenance**: Requires ongoing maintenance to ensure that indexer mocking remains robust and up-to-date.
29+
30+
---
31+
32+
More ADRs can be found in the [docs/ADR](../README.md) directory.

docs/ADR/feature/SupportForMethods.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Decision on Supporting Methods
2+
3+
## Context
4+
5+
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
6+
flexibility and usability.
7+
8+
The following type of methods must be supported
9+
- __Asynchronous__ with Task<>, Task, CancellationToken
10+
- __Overloaded__ methods in a way that keeps the required effort to setup the mock to a minimum.
11+
- __Generic__ Including the 'where' __constraints__.
12+
- __Out__ and __ref__ attributes on the method parameters.
13+
14+
## Decision
15+
16+
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](https://github.com/oswaldsql/MiniMock/issues/5)
17+
18+
Methods must be mockable using the following parameters
19+
20+
- Call : A Delegate matching the method signature with functionality to be executed.
21+
- Throw : An exception to be thrown when the method is called.
22+
- Return : A value to be returned when the method is called.
23+
- ReturnValues : A sequence of values to be returned when the method is called multiple times.
24+
- () : Methods returning `void` can be mocked using an empty delegate.
25+
26+
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.".
27+
28+
__Asynchronous__ methods are supported. Helper methods are provided to simplify the testing of asynchronous methods. Overloads of the following helper methods are added
29+
30+
- Return : Allows for returning either a Task object or the object to be wrapped in the task object.
31+
- ReturnValues : Allows for returning either a sequence of Task objects or a sequence of objects to be wrapped in task objects.
32+
- () : Methods returning Task can also use the empty delegate.
33+
34+
__Overloaded__ methods can either be mocked explicitly by using `Call` or collectively using the following
35+
36+
- Throw : An exception to be thrown when calling any of the overwritten methods.
37+
- Return : A value to be returned when a method with that return type is called.
38+
- ReturnValues : A sequence of values to be returned when a method with those return types is called multiple times.
39+
- () : Methods returning `void` or `Task` can be mocked using an empty delegate.
40+
41+
Generic methods are supported. The generic type is passed as a type parameter to the 'call' labmda method.
42+
43+
## Consequences
44+
45+
### Positive:
46+
47+
- **Comprehensive**: Ensures that the framework can handle a wide variety of method types.
48+
- **Flexibility**: Provides developers with the ability to mock different kinds of methods, enhancing the framework's usability.
49+
50+
### Negative:
51+
52+
- **Complexity**: Supporting all standard methods adds complexity to the framework.
53+
- **Ref Values**: Current issues with methods returning `ref` values need to be resolved, which may require significant effort.
54+
55+
---
56+
57+
More ADRs can be found in the [docs/ADR](../README.md) directory.

0 commit comments

Comments
 (0)