You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ADR/README.md
+4-15Lines changed: 4 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Architecture Decision Records (ADRs) are documents that capture important archit
4
4
5
5
All the ADRs have been approved and are considered final decisions for the project.
6
6
7
-
## General ADRs
7
+
## General ADRs[TL;DR](general/TLDR.md)
8
8
9
9
-[Do We __Really__ Need a New Mocking Framework?](general/DoWeNeedANewMockingFramework.md) - Deciding whether to build a new mocking framework.
10
10
-[Matching Target API in Mock API](general/MatchingTargetApi.md) - Ensures the mock API closely mirrors the target API.
@@ -13,27 +13,16 @@ All the ADRs have been approved and are considered final decisions for the proje
13
13
-[No Dependencies to Shared Libraries](general/NoDependencies.md) - Avoid dependencies on shared libraries.
14
14
-[Documentation and Examples](general/DocumentationAndExamples.md) - Approach to documentation and examples for the framework.
15
15
-[Logging and Debugging](general/LoggingAndDebugging.md) - Approach to logging and debugging within the framework.
16
-
-[Creating Mocks](general/CreatingMocks.md) - Decision on how to create mocks in the framework.
17
16
18
-
## Feature Specific ADRs
17
+
## Feature Specific ADRs[TL;DR](feature/TLDR.md)
19
18
20
-
-[Support for Classes and Interfaces](feature/SupportForClassesAndInterfaces.md) - Decision on supporting classes and interfaces in the mocking framework.
19
+
-[Support for Classes and Interfaces](feature/SupportForClassesAndInterfaces.md) - How should classes and interfaces be supported.
21
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
22
-[Support for Methods](feature/SupportForMethods.md) - Decision on supporting methods in the mocking framework.
23
23
-[Support for Properties](feature/SupportForProperties.md) - Decision on supporting properties in the mocking framework.
24
24
-[Support for Events](feature/SupportForEvents.md) - Decision on supporting events in the mocking framework.
25
25
-[Support for Indexers](feature/SupportForIndexers.md) - Decision on supporting indexers in the mocking framework.
26
-
- Special cases
27
-
-[Allowing Skipping Arguments in Mock Setup](feature/SupportSkippingArguments.md) - Allows skipping arguments in mock setups for flexibility.
28
-
-[Support for Protected Methods](feature/SupportingProtectedMethods.md) - Decision on whether to support mocking protected methods.
29
-
-[Support for Generic Methods (WIP)](feature/SupportForGenericMethods.md) - Decision on supporting generic methods in the mocking framework.
30
-
-[Support for Asynchronous Methods (WIP)](feature/SupportForAsynchronousMethods.md) - Handling asynchronous methods in the mocking framework.
31
-
-[Support for Virtual Methods (WIP)](feature/SupportForVirtualMethods.md) - Decision on supporting virtual methods in the mocking framework.
32
-
-[Support for Overloads (WIP)](feature/SupportForOverloads.md) - Decision on supporting method overloads in the mocking framework.
33
-
-[Support for Out and Ref Parameters (WIP)](feature/SupportForOutAndRefParameters.md) - Decision on supporting out and ref parameters in the mocking framework.
34
-
-[Support for Internal Methods (WIP)](feature/SupportForInternalMethods.md) - Decision on supporting internal methods in the mocking framework.
35
-
-[Support for Abstract Classes (WIP)](feature/SupportForAbstractClasses.md) - Decision on supporting abstract classes in the mocking framework.
36
-
-[Support for Delegates (WIP)](feature/SupportForDelegates.md) - Decision on supporting delegates in the mocking framework.
Copy file name to clipboardExpand all lines: docs/ADR/feature/CreatingMocks.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ In the MiniMock framework, there is a need to establish a standardized approach
7
7
## Decision
8
8
9
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.
Copy file name to clipboardExpand all lines: docs/ADR/feature/SupportForConstructors.md
+14-10Lines changed: 14 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,29 +2,33 @@
2
2
3
3
## Context
4
4
5
-
In the MiniMock framework, there is a need to determine the scope of support for mocking constructors. Initially, the framework will support only classes with parameterless constructors.
6
-
This decision simplifies the initial implementation and allows for a gradual introduction of more complex constructor support.
5
+
In the MiniMock framework, there is a need to determine the scope of support for mocking constructors.
7
6
8
7
## Decision
9
8
10
-
The MiniMock framework will initially support mocking only classes with parameterless constructors.
11
-
A plan for adding support for classes with parameterized constructors is being developed and will be implemented in future iterations.
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.
12
11
13
-
Since the main focus of the framework is to provide a simple and easy-to-use mocking solution for interfaces and classes,
14
-
the decision to start with parameterless constructors aligns with this goal. See ADR [Support For Classes and Interfaces](SupportForClassesAndInterfaces.md) for more information.
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.
15
19
16
20
## Consequences
17
21
18
22
### Positive:
19
23
20
24
-**Simplicity**: Simplifies the initial implementation by focusing on parameterless constructors.
21
-
-**Incremental Development**: Allows for a phased approach to adding more complex constructor support.
22
-
-**Usability**: Provides immediate value by supporting a common use case.
25
+
-**Flexibility**: Supporting parameterized constructors and overloads provides more flexibility for developers.
26
+
-**Compatibility**: Ensures compatibility with dependency injection, making the framework more versatile.
23
27
24
28
### Negative:
25
29
26
-
-**Limited Scope**: Initial support is limited to classes with parameterless constructors, which may not cover all use cases.
27
-
-**Future Work**: Additional effort will be required to implement support for parameterized constructors.
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.
Copy file name to clipboardExpand all lines: docs/ADR/feature/SupportForMethods.md
+22-2Lines changed: 22 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,14 @@
2
2
3
3
## Context
4
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 flexibility and usability. However, there are currently issues with supporting methods that return `ref` values, which need to be addressed.
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.
6
13
7
14
## Decision
8
15
@@ -18,7 +25,20 @@ Methods must be mockable using the following parameters
18
25
19
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.".
20
27
21
-
Special cases like [Overloads], [Generic Methods] and [Async Methods] have dedicated ADRs.
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.
0 commit comments