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
2 changes: 1 addition & 1 deletion Docs/agents/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ dotnet run -c Release --project Benchmarks/aweXpect.Mockolate.Benchmarks -- --fi
## Documentation

- The user documentation is `README.md` and `Docs/pages/*.md`. The pages are published to [docs.testably.org](https://docs.testably.org/aweXpect/extensions/aweXpect.Mockolate/): after a successful Build on `main`, `notify-docs-site.yml` triggers a rebuild of `Testably/Testably.Site`.
- `Docs/pages/00-index.md` embeds the README through the `{README}` placeholder. Keep the overview table in the README and the tables on the pages in sync when adding an expectation.
- `Docs/pages/00-index.md` is the docs landing page and is maintained separately from the README. Keep the overview tables in the README and in `00-index.md` and the tables on the pages in sync when adding an expectation.
- The README is the package readme. `Pack` rewrites its badges for the release version.
- `Docs/agents/` holds this guide and is not published.

Expand Down
71 changes: 67 additions & 4 deletions Docs/pages/00-index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,71 @@
# aweXpect.Mockolate
import PackageInstall from '@site/src/components/PackageInstall';

[![Nuget](https://img.shields.io/nuget/v/aweXpect.Mockolate)](https://www.nuget.org/packages/aweXpect.Mockolate)
# aweXpect.Mockolate

[aweXpect.Mockolate](https://github.com/Testably/aweXpect.Mockolate) contains expectations to verify interactions with
mocks from [Mockolate](https://github.com/Testably/Mockolate).
mocks from [Mockolate](/Mockolate). It is an extension for [aweXpect](/aweXpect).

## Installation

<PackageInstall package="aweXpect.Mockolate" />

The package adds its expectations to aweXpect, so the test project also needs the
[`aweXpect`](/aweXpect/getting-started) package.

## At a glance

```csharp
IPlayer player = IPlayer.CreateMock();
player.Play("Let It Be");
player.Stop();

// verify how often a method was invoked
await Expect.That(player.Mock.Verify.Play("Let It Be")).Once();

// verify the order of the interactions
await Expect.That(player.Mock.Verify.Play("Let It Be")).Then(m => m.Stop());

// verify that no interaction was forgotten
await Expect.That(player.Mock.Verify).AllInteractionsAreVerified();
```

A failing verification lists the matching and all interactions with the mock. If the track was played twice, `Once()`
would fail with:

```text title="Failure message"
Expected that the MusicStore.IPlayer mock
invoked method Play(Let It Be) exactly once,
but it was found twice

Matching Interactions:
[
invoke method Play(Let It Be),
invoke method Play(Let It Be)
]

All Interactions:
[
invoke method Play(Let It Be),
invoke method Play(Let It Be)
]
```

## Overview

| Expectation | Summary |
|-----------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [`Once`, `Twice`, `Never`](./01-interaction-count.md) | the interaction happened exactly once, twice or never |
| [`AtLeastOnce`, `AtLeastTwice`, `AtLeast`](./01-interaction-count.md) | the interaction happened at least the given number of times |
| [`AtMostOnce`, `AtMostTwice`, `AtMost`](./01-interaction-count.md) | the interaction happened at most the given number of times |
| [`Exactly`, `Between`](./01-interaction-count.md) | the interaction happened exactly or in a range of times |
| [`Times`](./01-interaction-count.md) | the number of interactions satisfies a predicate |
| [`Then`](./02-interaction-order.md) | the interactions happened in the given order |
| [`AllInteractionsAreVerified`](./03-interactions-and-setups.md#all-interactions-are-verified) | every interaction with the mock was verified |
| [`AllSetupsAreUsed`](./03-interactions-and-setups.md#all-setups-are-used) | every setup of the mock was used |

Verifications of a minimum number of interactions and of their order can wait for interactions that happen in the
background with `Within(timeout)`, see [Waiting for interactions](./01-interaction-count.md#waiting-for-interactions)
and [Interaction order](./02-interaction-order.md#waiting-for-interactions).

{README}
The [HTTP content matchers](./04-http-content-matchers.md) add JSON matchers for `It.IsHttpContent()` in setups and
verifications of a mocked `HttpClient`.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
Expectations to verify interactions with mocks from [Mockolate](https://github.com/Testably/Mockolate) for
[aweXpect](https://github.com/Testably/aweXpect).

## Installation

```shell
dotnet add package aweXpect.Mockolate
```

The package adds its expectations to aweXpect, so the test project also needs the
[`aweXpect`](https://www.nuget.org/packages/aweXpect) package.

## At a glance

```csharp
Expand Down
Loading