Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved docs on BeLowerCased and BeUpperCased for mixed strings #1792

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 - [#1792](https://github.com/fluentassertions/fluentassertions/pull/1792)

## 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