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 548562e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion 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 Expand Up @@ -122,4 +143,4 @@ If you prefer a more fluent syntax than `Exactly.Times(4)`, `AtLeast.Times(4)` a
theString.Should().Contain("is a", 4.TimesExactly()); // equivalent to Exactly.Times(4)
theString.Should().Contain("is a", 4.TimesOrMore()); // equivalent to AtLeast.Times(4)
theString.Should().Contain("is a", 4.TimesOrLess()); // equivalent to AtMost.Times(4)
```
```

0 comments on commit 548562e

Please sign in to comment.