Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Docs/pages/01-create-mocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ var classMock = Mock.Create<MyChocolateDispenser>(
- 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 `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<T>(params Action<IMockSetup<T>>[] setups)`:
- Automatically initialize all mocks of type T with the given setups when they are created.
Expand Down
14 changes: 11 additions & 3 deletions Docs/pages/02-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ sut.SetupMock.Method.DispenseAsync(It.IsAny<string>(), It.IsAny<int>())
Mockolate provides flexible parameter matching for method setups and verifications:

- `It.IsAny<T>()`: Matches any value of type `T`.
- `It.Is<T>(value)`: Matches a specific value. With `.Using(IEqualityComparer<T>)`, you can provide a custom equality comparer.
- `It.IsOneOf<T>(params T[] values)`: Matches any of the given values. With `.Using(IEqualityComparer<T>)`, you can provide a custom equality comparer.
- `It.Is<T>(value)`: Matches a specific value. With `.Using(IEqualityComparer<T>)`, you can provide a custom equality
comparer.
- `It.IsOneOf<T>(params T[] values)`: Matches any of the given values. With `.Using(IEqualityComparer<T>)`, you can
provide a custom equality comparer.
- `It.IsNull<T>()`: Matches null.
- `It.IsTrue()`/`It.IsFalse()`: Matches boolean true/false.
- `It.IsInRange(min, max)`: Matches a number within the given range. You can append `.Exclusive()` to exclude the
Expand All @@ -65,9 +67,15 @@ Mockolate provides flexible parameter matching for method setups and verificatio
predicates.
- `It.IsRef<T>(…)`/`It.IsAnyRef<T>(…)`: Matches and sets ref parameters, supports value setting and
predicates.
- `It.Matches<string>(pattern)`: Matches strings using wildcard patterns (`*` and `?`). With `.AsRegex()`, you can use regular expressions instead.
- `It.Matches<string>(pattern)`: Matches strings using wildcard patterns (`*` and `?`). With `.AsRegex()`, you can use
regular expressions instead.
- `It.Satisfies<T>(predicate)`: Matches values based on a predicate.

When the method name is unique (no overloads), you can omit the argument matchers for simpler setups:

- `Match.AnyParameters()`: Matches any parameters.
- `Match.Parameters(Func<NamedParameterValue[], bool> predicate)`: Matches the parameters based on a predicate.

Comment thread
vbreuss marked this conversation as resolved.
#### Parameter Interaction

With `Do`, you can register a callback for individual parameters of a method setup. This allows you to implement side
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ var classMock = Mock.Create<MyChocolateDispenser>(
- 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.
values, if no explicit setup is defined.
- If `true`, the mock will not call any base class implementations.
- `Initialize<T>(params Action<IMockSetup<T>>[] setups)`:
- Automatically initialize all mocks of type T with the given setups when they are created.
Expand Down Expand Up @@ -224,6 +223,13 @@ Mockolate provides flexible parameter matching for method setups and verificatio
regular expressions instead.
- `It.Satisfies<T>(predicate)`: Matches values based on a predicate.

When the method name is unique (no overloads), you can omit the argument matchers for simpler setups:

- `Match.AnyParameters()`: Matches any parameters.
- `Match.Parameters(Func<NamedParameterValue[], bool> predicate)`: Matches the parameters based on a predicate.

Comment thread
vbreuss marked this conversation as resolved.
```csharp

#### Parameter Interaction

With `Do`, you can register a callback for individual parameters of a method setup. This allows you to implement side
Expand Down
Loading