diff --git a/Docs/pages/01-create-mocks.md b/Docs/pages/01-create-mocks.md index fa2c5188..76a28abe 100644 --- a/Docs/pages/01-create-mocks.md +++ b/Docs/pages/01-create-mocks.md @@ -44,8 +44,8 @@ var classMock = Mock.Create( - 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(params Action>[] setups)`: - Automatically initialize all mocks of type T with the given setups when they are created. diff --git a/Docs/pages/02-setup.md b/Docs/pages/02-setup.md index 929f8541..0fd64d46 100644 --- a/Docs/pages/02-setup.md +++ b/Docs/pages/02-setup.md @@ -55,8 +55,10 @@ sut.SetupMock.Method.DispenseAsync(It.IsAny(), It.IsAny()) Mockolate provides flexible parameter matching for method setups and verifications: - `It.IsAny()`: Matches any value of type `T`. -- `It.Is(value)`: Matches a specific value. With `.Using(IEqualityComparer)`, you can provide a custom equality comparer. -- `It.IsOneOf(params T[] values)`: Matches any of the given values. With `.Using(IEqualityComparer)`, you can provide a custom equality comparer. +- `It.Is(value)`: Matches a specific value. With `.Using(IEqualityComparer)`, you can provide a custom equality + comparer. +- `It.IsOneOf(params T[] values)`: Matches any of the given values. With `.Using(IEqualityComparer)`, you can + provide a custom equality comparer. - `It.IsNull()`: 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 @@ -65,9 +67,15 @@ Mockolate provides flexible parameter matching for method setups and verificatio predicates. - `It.IsRef(…)`/`It.IsAnyRef(…)`: Matches and sets ref parameters, supports value setting and predicates. -- `It.Matches(pattern)`: Matches strings using wildcard patterns (`*` and `?`). With `.AsRegex()`, you can use regular expressions instead. +- `It.Matches(pattern)`: Matches strings using wildcard patterns (`*` and `?`). With `.AsRegex()`, you can use + regular expressions instead. - `It.Satisfies(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 predicate)`: Matches the parameters based on a predicate. + #### Parameter Interaction With `Do`, you can register a callback for individual parameters of a method setup. This allows you to implement side diff --git a/README.md b/README.md index 1371535b..183d0a8e 100644 --- a/README.md +++ b/README.md @@ -122,8 +122,7 @@ var classMock = Mock.Create( - 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(params Action>[] setups)`: - Automatically initialize all mocks of type T with the given setups when they are created. @@ -224,6 +223,13 @@ Mockolate provides flexible parameter matching for method setups and verificatio regular expressions instead. - `It.Satisfies(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 predicate)`: Matches the parameters based on a predicate. + +```csharp + #### Parameter Interaction With `Do`, you can register a callback for individual parameters of a method setup. This allows you to implement side