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
27 changes: 20 additions & 7 deletions Docs/pages/04-verify-interactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,25 @@ If the order is incorrect or a call is missing, a `MockVerificationException` wi

## Check for unexpected interactions

You can check if all interactions with the mock have been verified using `ThatAllInteractionsAreVerified`:
1. **ThatAllInteractionsAreVerified**:
You can check if all interactions with the mock have been verified using `ThatAllInteractionsAreVerified`:

```csharp
// Returns true if all interactions have been verified before
bool allVerified = sut.VerifyMock.ThatAllInteractionsAreVerified();
```
```csharp
// Returns true if all interactions have been verified before
bool allVerified = sut.VerifyMock.ThatAllInteractionsAreVerified();
```

This is useful for ensuring that your test covers all interactions and that no unexpected calls were made.
If any interaction was not verified, this method returns `false`.


2. **ThatAllSetupsAreUsed**:
You can check if all registered setups on the mock have been used using `ThatAllSetupsAreUsed`:

```csharp
// Returns true if all setups have been used
bool allUsed = sut.VerifyMock.ThatAllSetupsAreUsed();
```

This is useful for ensuring that your test covers all interactions and that no unexpected calls were made.
If any interaction was not verified, this method returns `false`.
This is useful for ensuring that your test setup and test execution match.
If any setup was not used, this method returns `false`.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ Mockolate provides flexible parameter matching for method setups and verificatio
- `It.Is<T>(value)`: Matches a specific value.
- `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 minimum and maximum value.
- `It.IsInRange(min, max)`: Matches a number within the given range. You can append `.Exclusive()` to exclude the
minimum and maximum value.
- `It.IsOut<T>(…)`/`It.IsRef<T>(…)`: Matches and sets out/ref parameters, supports value setting and
predicates.

Expand Down Expand Up @@ -437,12 +438,25 @@ If the order is incorrect or a call is missing, a `MockVerificationException` wi

### Check for unexpected interactions

You can check if all interactions with the mock have been verified using `ThatAllInteractionsAreVerified`:
1. **ThatAllInteractionsAreVerified**:
You can check if all interactions with the mock have been verified using `ThatAllInteractionsAreVerified`:

```csharp
// Returns true if all interactions have been verified before
bool allVerified = sut.VerifyMock.ThatAllInteractionsAreVerified();
```
```csharp
// Returns true if all interactions have been verified before
bool allVerified = sut.VerifyMock.ThatAllInteractionsAreVerified();
```

This is useful for ensuring that your test covers all interactions and that no unexpected calls were made.
If any interaction was not verified, this method returns `false`.


2. **ThatAllSetupsAreUsed**:
You can check if all registered setups on the mock have been used using `ThatAllSetupsAreUsed`:

```csharp
// Returns true if all setups have been used
bool allUsed = sut.VerifyMock.ThatAllSetupsAreUsed();
```

This is useful for ensuring that your test covers all interactions and that no unexpected calls were made.
If any interaction was not verified, this method returns `false`.
This is useful for ensuring that your test setup and test execution match.
If any setup was not used, this method returns `false`.
Loading