Skip to content

Conversation

@weitzhandler
Copy link
Contributor

Adds the following Shoulds to string, to assert its casing:

  • BeUpper
  • NotBeUpper
  • BeLower
  • NotBeLower

Fixes #1356

@weitzhandler weitzhandler force-pushed the string-case branch 3 times, most recently from 969e2fe to 80883f9 Compare July 17, 2020 10:30
@jnyrup
Copy link
Member

jnyrup commented Jul 19, 2020

Continuing the discussion about API naming...
The BCL also has ToTitleCase, which does use the "Case" suffix, so I'd like to keep the door open for alternative names a bit.
I think BeUpperCase reads closer to regular prose.
While we should get inspiration from BCL, it does not need to dictate our choices.

How does char.IsUpper handle culture?

I recall that char.IsUpper only returns true for characters that are both letters and uppercase.
That clearly justifies that we should have all four combinations, as a character not being upper case does not imply that it is lower case, e.g. digits are neither lower case nor upper case.

I think the test suite would benefit from tests like these to reflect those cases.

subject = "A1";

Action act = () => subject.Should().BeUpper();

act.Should().Throw();
subject = "a1";

Action act = () => subject.Should().NotBeUpper();

act.Should().NotThrow();

and the complementary for [Not]BeLower.

Copy link
Member

@dennisdoomen dennisdoomen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this enhancement. I've left some suggestions and corrections in-line. Also, would you be willing to update releases.md and strings.md under https://github.com/fluentassertions/fluentassertions/tree/develop/docs/_pages as well?

weitzhandler added a commit to weitzhandler/fluentassertions that referenced this pull request Jul 27, 2020
weitzhandler added a commit to weitzhandler/fluentassertions that referenced this pull request Jul 27, 2020
weitzhandler added a commit to weitzhandler/fluentassertions that referenced this pull request Jul 27, 2020
@weitzhandler
Copy link
Contributor Author

cca1d01:

  • Resolved comments
  • Rebased on upstream/develop
  • Updated docs

@dennisdoomen dennisdoomen requested a review from jnyrup July 28, 2020 04:50
Copy link
Member

@jnyrup jnyrup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍
Just a few nits, before it's ready to get merged.

weitzhandler and others added 3 commits July 28, 2020 20:20
Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
@weitzhandler weitzhandler requested a review from jnyrup July 28, 2020 17:21
@jnyrup jnyrup merged commit cfc4dc5 into fluentassertions:develop Jul 28, 2020
@weitzhandler weitzhandler deleted the string-case branch July 28, 2020 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: lower/upper case assertions

3 participants