From 7519d19088340c9b44112a809f59d5fb9d89e5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sun, 1 Feb 2026 06:25:31 +0100 Subject: [PATCH 1/3] docs: document prerequisites (installed .NET 10 SDK) --- Docs/pages/00-index.md | 10 ++++-- README.md | 69 ++++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/Docs/pages/00-index.md b/Docs/pages/00-index.md index 584a739d..a6cf0bc1 100644 --- a/Docs/pages/00-index.md +++ b/Docs/pages/00-index.md @@ -14,12 +14,18 @@ Framework 4.8. ## Getting Started -1. Install the [`Mockolate`](https://www.nuget.org/packages/Mockolate) nuget package +1. Check prerequisites: + Although Mockolate supports multiple .NET Standard 2.0 compatible frameworks (including .NET Framework 4.8), you must + have the [.NET 10 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) installed to build and compile + Mockolate. This is required because Mockolate + leverages [C# 14 extension members](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods#declare-extension-members). + +2. Install the [`Mockolate`](https://www.nuget.org/packages/Mockolate) nuget package ```ps dotnet add package Mockolate ``` -2. Create and use the mock +3. Create and use the mock ```csharp using Mockolate; diff --git a/README.md b/README.md index d59ccfa6..ccaa511f 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,8 @@ [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FaweXpect%2FMockolate%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/aweXpect/Mockolate/main) **Mockolate** is a modern, strongly-typed, AOT-compatible mocking library for .NET, powered by source generators. It -enables fast, -compile-time validated mocks for interfaces and classes, supporting .NET Standard 2.0, .NET 8, .NET 10, and .NET -Framework 4.8. +enables fast, compile-time validated mocks for interfaces and classes, supporting .NET Standard 2.0, .NET 8, .NET 10, +and .NET Framework 4.8. - **Source generator-based**: No runtime proxy generation, fast and reliable. - **Strongly-typed**: Setup and verify mocks with full IntelliSense and compile-time safety. @@ -19,12 +18,18 @@ Framework 4.8. ## Getting Started -1. Install the [`Mockolate`](https://www.nuget.org/packages/Mockolate) nuget package +1. Check prerequisites: + Although Mockolate supports multiple .NET Standard 2.0 compatible frameworks (including .NET Framework 4.8), you must + have the [.NET 10 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) installed to build and compile + Mockolate. This is required because Mockolate + leverages [C# 14 extension members](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods#declare-extension-members). + +2. Install the [`Mockolate`](https://www.nuget.org/packages/Mockolate) nuget package ```ps dotnet add package Mockolate ``` -2. Create and use the mock +3. Create and use the mock ```csharp using Mockolate; @@ -118,37 +123,37 @@ var classMock = Mock.Create( **`MockBehavior` options** - `ThrowWhenNotSetup` (bool): - - If `false` (default), the mock will return a default value (see `DefaultValue`). - - If `true`, the mock will throw an exception when a method or property is called without a setup. + - If `false` (default), the mock will return a default value (see `DefaultValue`). + - If `true`, the mock will throw an exception when a method or property is called without a setup. - `SkipBaseClass` (bool): - - If `false` (default), the mock will call the base class implementation and use its return values as default - values, if no explicit setup is defined. - - If `true`, the mock will not call any base class implementations. + - If `false` (default), the mock will call the base class implementation and use its return values as default + values, if no explicit setup is defined. + - If `true`, the mock will not call any base class implementations. - `Initialize(params Action>[] setups)`: - - Automatically initialize all mocks of type T with the given setups when they are created. - - The callback can optionally receive an additional counter parameter which allows to differentiate between multiple - instances. This is useful when you want to ensure that you can distinguish between different automatically created - instances. + - Automatically initialize all mocks of type T with the given setups when they are created. + - The callback can optionally receive an additional counter parameter which allows to differentiate between multiple + instances. This is useful when you want to ensure that you can distinguish between different automatically created + instances. - `DefaultValue` (IDefaultValueGenerator): - - Customizes how default values are generated for methods/properties that are not set up. - - The default implementation provides sensible defaults for the most common use cases: - - Empty collections for collection types (e.g., `IEnumerable`, `List`, etc.) - - Empty string for `string` - - Completed tasks for `Task`, `Task`, `ValueTask` and `ValueTask` - - Tuples with recursively defaulted values - - `null` for other reference types - - You can provide custom default values for specific types using `.WithDefaultValueFor()`: - ```csharp - var behavior = MockBehavior.Default - .WithDefaultValueFor(() => "default") - .WithDefaultValueFor(() => 42); - var sut = Mock.Create(behavior); - ``` - This is useful when you want mocks to return specific default values for certain types instead of the standard - defaults (e.g., `null`, `0`, empty strings). + - Customizes how default values are generated for methods/properties that are not set up. + - The default implementation provides sensible defaults for the most common use cases: + - Empty collections for collection types (e.g., `IEnumerable`, `List`, etc.) + - Empty string for `string` + - Completed tasks for `Task`, `Task`, `ValueTask` and `ValueTask` + - Tuples with recursively defaulted values + - `null` for other reference types + - You can provide custom default values for specific types using `.WithDefaultValueFor()`: + ```csharp + var behavior = MockBehavior.Default + .WithDefaultValueFor(() => "default") + .WithDefaultValueFor(() => 42); + var sut = Mock.Create(behavior); + ``` + This is useful when you want mocks to return specific default values for certain types instead of the standard + defaults (e.g., `null`, `0`, empty strings). - `.UseConstructorParametersFor(object?[])`: - - Configures constructor parameters to use when creating mocks of type `T`, unless explicit parameters are provided - during mock creation via `BaseClass.WithConstructorParameters(…)`. + - Configures constructor parameters to use when creating mocks of type `T`, unless explicit parameters are provided + during mock creation via `BaseClass.WithConstructorParameters(…)`. ### Using a factory for shared behavior From 9d209e38bf29eb2551f816423b7b91b6c44627c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sun, 1 Feb 2026 06:26:55 +0100 Subject: [PATCH 2/3] Remove colon --- Docs/pages/00-index.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Docs/pages/00-index.md b/Docs/pages/00-index.md index a6cf0bc1..c57c9d20 100644 --- a/Docs/pages/00-index.md +++ b/Docs/pages/00-index.md @@ -14,7 +14,7 @@ Framework 4.8. ## Getting Started -1. Check prerequisites: +1. Check prerequisites Although Mockolate supports multiple .NET Standard 2.0 compatible frameworks (including .NET Framework 4.8), you must have the [.NET 10 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) installed to build and compile Mockolate. This is required because Mockolate diff --git a/README.md b/README.md index ccaa511f..8b66abc4 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ and .NET Framework 4.8. ## Getting Started -1. Check prerequisites: +1. Check prerequisites Although Mockolate supports multiple .NET Standard 2.0 compatible frameworks (including .NET Framework 4.8), you must have the [.NET 10 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) installed to build and compile Mockolate. This is required because Mockolate From 0ec6df4cb3b37764e59bc1e3d3d51c82110ce709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sun, 1 Feb 2026 06:29:08 +0100 Subject: [PATCH 3/3] Avoid tabs --- README.md | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 8b66abc4..109c23b8 100644 --- a/README.md +++ b/README.md @@ -123,37 +123,37 @@ var classMock = Mock.Create( **`MockBehavior` options** - `ThrowWhenNotSetup` (bool): - - If `false` (default), the mock will return a default value (see `DefaultValue`). - - If `true`, the mock will throw an exception when a method or property is called without a setup. + - If `false` (default), the mock will return a default value (see `DefaultValue`). + - If `true`, the mock will throw an exception when a method or property is called without a setup. - `SkipBaseClass` (bool): - - If `false` (default), the mock will call the base class implementation and use its return values as default - values, if no explicit setup is defined. - - If `true`, the mock will not call any base class implementations. + - If `false` (default), the mock will call the base class implementation and use its return values as default + values, if no explicit setup is defined. + - If `true`, the mock will not call any base class implementations. - `Initialize(params Action>[] setups)`: - - Automatically initialize all mocks of type T with the given setups when they are created. - - The callback can optionally receive an additional counter parameter which allows to differentiate between multiple - instances. This is useful when you want to ensure that you can distinguish between different automatically created - instances. + - Automatically initialize all mocks of type T with the given setups when they are created. + - The callback can optionally receive an additional counter parameter which allows to differentiate between multiple + instances. This is useful when you want to ensure that you can distinguish between different automatically created + instances. - `DefaultValue` (IDefaultValueGenerator): - - Customizes how default values are generated for methods/properties that are not set up. - - The default implementation provides sensible defaults for the most common use cases: - - Empty collections for collection types (e.g., `IEnumerable`, `List`, etc.) - - Empty string for `string` - - Completed tasks for `Task`, `Task`, `ValueTask` and `ValueTask` - - Tuples with recursively defaulted values - - `null` for other reference types - - You can provide custom default values for specific types using `.WithDefaultValueFor()`: - ```csharp - var behavior = MockBehavior.Default - .WithDefaultValueFor(() => "default") - .WithDefaultValueFor(() => 42); - var sut = Mock.Create(behavior); - ``` - This is useful when you want mocks to return specific default values for certain types instead of the standard - defaults (e.g., `null`, `0`, empty strings). + - Customizes how default values are generated for methods/properties that are not set up. + - The default implementation provides sensible defaults for the most common use cases: + - Empty collections for collection types (e.g., `IEnumerable`, `List`, etc.) + - Empty string for `string` + - Completed tasks for `Task`, `Task`, `ValueTask` and `ValueTask` + - Tuples with recursively defaulted values + - `null` for other reference types + - You can provide custom default values for specific types using `.WithDefaultValueFor()`: + ```csharp + var behavior = MockBehavior.Default + .WithDefaultValueFor(() => "default") + .WithDefaultValueFor(() => 42); + var sut = Mock.Create(behavior); + ``` + This is useful when you want mocks to return specific default values for certain types instead of the standard + defaults (e.g., `null`, `0`, empty strings). - `.UseConstructorParametersFor(object?[])`: - - Configures constructor parameters to use when creating mocks of type `T`, unless explicit parameters are provided - during mock creation via `BaseClass.WithConstructorParameters(…)`. + - Configures constructor parameters to use when creating mocks of type `T`, unless explicit parameters are provided + during mock creation via `BaseClass.WithConstructorParameters(…)`. ### Using a factory for shared behavior