Skip to content

Commit

Permalink
Improved docs on BeLowerCased and BeUpperCased for mixed strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisdoomen committed Jan 29, 2022
1 parent 81368ad commit e8fe1e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Src/FluentAssertions/Primitives/StringAssertions.cs
Expand Up @@ -1285,6 +1285,11 @@ public AndConstraint<TAssertions> BeNullOrWhiteSpace(string because = "", params
/// <summary>
/// Asserts that all characters in a string are in upper casing.
/// </summary>
/// <remarks>
/// Be careful that numbers and special characters don't have casing, so <see cref="BeUpperCased"/>
/// will always fail on a string that contains anything but alphabetic characters.
/// In those cases, we recommend using <see cref="NotBeLowerCased"/>.
/// </remarks>
/// <param name="because">
/// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
Expand Down Expand Up @@ -1325,6 +1330,11 @@ public AndConstraint<TAssertions> NotBeUpperCased(string because = "", params ob
/// <summary>
/// Asserts that all characters in a string are in lower casing.
/// </summary>
/// <remarks>
/// Be careful that numbers and special characters don't have casing, so <see cref="BeLowerCased"/> will always fail on
/// a string that contains anything but alphabetic characters.
/// In those cases, we recommend using <see cref="NotBeUpperCased"/>.
/// </remarks>
/// <param name="because">
/// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
Expand Down
2 changes: 2 additions & 0 deletions docs/_pages/releases.md
Expand Up @@ -15,6 +15,8 @@ sidebar:

### Fixes

* Improved the documentation on `BeLowerCased` and `BeUpperCased` for strings with non-alphabetic characters - [#0000](https://github.com/fluentassertions/fluentassertions/pull/1791)

## 6.4.0

### What's New
Expand Down
7 changes: 7 additions & 0 deletions docs/_pages/strings.md
Expand Up @@ -18,12 +18,19 @@ theString.Should().NotBeEmpty("because the string is not empty");
theString.Should().HaveLength(0);
theString.Should().BeNullOrWhiteSpace(); // either null, empty or whitespace only
theString.Should().NotBeNullOrWhiteSpace();
```

To ensure the characters in a string are all (not) upper or lower cased, you can use the following assertions.

```csharp
theString.Should().BeUpperCased();
theString.Should().NotBeUpperCased();
theString.Should().BeLowerCased();
theString.Should().NotBeLowerCased();
```

However, be careful that numbers and special characters don't have casing, so `BeUpperCased` and `BeLowerCased` will always fail on a string that contains anything but alphabetic characters. In those cases, we recommend using `NotBeUpperCased` or `NotBeLowerCased`.

Obviously you’ll find all the methods you would expect for string assertions.

```csharp
Expand Down

0 comments on commit e8fe1e1

Please sign in to comment.