Skip to content
Merged
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
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Expectations to verify interactions with mocks from [Mockolate](https://github.c
## Features

### Interaction count

Verify that a method was called a specific number of times:

```csharp
Expand All @@ -30,6 +31,7 @@ await That(mock.VerifyMock.Invoked.MyMethod()).Exactly(2.Times()); // Exactly 2
```

### Interaction order

Verify that methods were called in a specific sequence:

```csharp
Expand All @@ -46,3 +48,35 @@ await That(mock.VerifyMock.Invoked.MyMethod(It.Is(1))).Then(
);
```

### Additional Verifications

#### All interactions are verified

With `AllInteractionsAreVerified` you can check whether all interactions with the mock have actually been verified. This
helps to detect unintended or forgotten calls.

```csharp
var mock = Mock.Create<IMyService>();
mock.MyMethod(1);
mock.MyMethod(2);

await That(mock.VerifyMock.Invoked.MyMethod(It.IsAny<int>())).AtLeastOnce();
// Succeeds, because the verification applies to both method calls.
await That(mock.VerifyMock).AllInteractionsAreVerified();
```

#### All setups are used

With `AllSetupsAreUsed` you can check whether all defined setups on the mock have actually been used. This ensures that
no setup configurations remain unused.

```csharp
var mock = Mock.Create<IMyService>();
mock.SetupMock.Method.MyMethod(It.Is(1)).Returns(10);
mock.SetupMock.Method.MyMethod(It.Is(2)).Returns(20);

mock.MyMethod(1);

// Fails, because the setup for MyMethod(2) was never used.
await That(mock.VerifyMock).AllSetupsAreUsed();
```
Loading