Skip to content

Commit

Permalink
Add more information about usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielsimard committed Mar 11, 2018
1 parent 9f5ddc2 commit 13ec6de
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct PersonFactoryMock {
```

In this case, our mock has one field `create` that will be used for mocking the function of the same name.
The mock signature is `Mock<Input, Ouput>`.
In this case we have two strings as input, so we use a tuple of strings instead.
Note that the mock can be cloned without losing his internal state because it uses inner mutability with ref counting.
Now we can implement the `trait`.

Expand All @@ -56,7 +58,7 @@ impl PersonFactory for PersonFactoryMock {
}
```

The only thing to do here is to pass the inputs in a tuple to the function `called`.
The only thing to do here is to pass the inputs in a tuple to the function `called` to match the mock signature.
To facilitate the use of the mock we can create a `new` function.

```rust
Expand Down

0 comments on commit 13ec6de

Please sign in to comment.