Skip to content
Merged
Changes from 1 commit
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
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,31 @@ 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.DoWork(1);
Comment thread
vbreuss marked this conversation as resolved.
Outdated

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