Skip to content

Commit

Permalink
Document the new functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
vbreuss committed Nov 9, 2023
1 parent b9750b5 commit 5b84065
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/_pages/strings.md
Expand Up @@ -75,6 +75,27 @@ theString.Should().EndWithEquivalentOf("a string");
theString.Should().NotEndWithEquivalentOf("a string");
```

All equivalency methods which end with "EquivalentOf" can be fine-tuned in its behaviour what differences to ignore.
For instance, if you want to ignore leading whitespace, use this:

```csharp
theString.Should().BeEquivalentTo("This is a string", o => o.IgnoringLeadingWhitespace());
```

The supported options are:

| Option | Behaviour |
| ---------------------------- | --------------------------------------------------------------- |
| `IgnoringLeadingWhitespace` | Ignores leading whitespace in the subject and the expectation. |
| `IgnoringTrailingWhitespace` | Ignores trailing whitespace in the subject and the expectation. |
| `IgnoringCase` | Compares the strings case-insensitive. |
| `IgnoringNewlines` | Removes all newlines in the subject and expectation. |

You can also specify a custom string comparer via
```csharp
theString.Should().BeEquivalentTo("THIS IS A STRING", o => o.Using(StringComparer.OrdinalIgnoreCase));
```

For the `Match`, `NotMatch`, `MatchEquivalentOf`, and `NotMatchEquivalentOf` methods we support wildcards.

The pattern can be a combination of literal and wildcard characters, but it doesn't support regular expressions.
Expand Down

0 comments on commit 5b84065

Please sign in to comment.