diff --git a/Src/FluentAssertions/Primitives/StringAssertions.cs b/Src/FluentAssertions/Primitives/StringAssertions.cs index 17b34cf5bd..c75f0ddce1 100644 --- a/Src/FluentAssertions/Primitives/StringAssertions.cs +++ b/Src/FluentAssertions/Primitives/StringAssertions.cs @@ -1285,6 +1285,11 @@ public AndConstraint BeNullOrWhiteSpace(string because = "", params /// /// Asserts that all characters in a string are in upper casing. /// + /// + /// Be careful that numbers and special characters don't have casing, so + /// will always fail on a string that contains anything but alphabetic characters. + /// In those cases, we recommend using . + /// /// /// A formatted phrase as is supported by explaining why the assertion /// is needed. If the phrase does not start with the word because, it is prepended automatically. @@ -1325,6 +1330,11 @@ public AndConstraint NotBeUpperCased(string because = "", params ob /// /// Asserts that all characters in a string are in lower casing. /// + /// + /// Be careful that numbers and special characters don't have casing, so will always fail on + /// a string that contains anything but alphabetic characters. + /// In those cases, we recommend using . + /// /// /// A formatted phrase as is supported by explaining why the assertion /// is needed. If the phrase does not start with the word because, it is prepended automatically. diff --git a/docs/_pages/releases.md b/docs/_pages/releases.md index 53e06e60a2..a9a7c1ca45 100644 --- a/docs/_pages/releases.md +++ b/docs/_pages/releases.md @@ -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 diff --git a/docs/_pages/strings.md b/docs/_pages/strings.md index 41bd0be9dd..aae2b12148 100644 --- a/docs/_pages/strings.md +++ b/docs/_pages/strings.md @@ -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