question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BeLowerCased() results in failing tests with only lower case characters.

See original GitHub issue

Description

Just introduced using BeLowerCased() into one of our tests where we want to assert that a file path is lower case, but the result is not as expected. The response I get from the failing test is as follows:

Expected all characters in carFolderPath to be lower cased, but found "\files\f7f9de7c-90f4-46a3-9ceb-97af53f495e3\carfiles\abc123".

Perhaps the back slash is considered an upper case character in some way?

Complete minimal example reproducing the issue

// Arrange 
var input = @"\test\with\lower\cased\string";

// Assert
input.Should().BeLowerCased();

Expected behavior:

Test to pass

Actual behavior:

Test fails

Versions

Fluentassertions: 6.3.0 .NET 5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dennisdoomencommented, Jan 10, 2022

Let’s keep it open so we update the documentation.

0reactions
MEmanuelssoncommented, Jan 10, 2022

NotBeUpperCased does the trick in this case, however not completely clear by the description of the function that this is how it works.

I thought that anything that for instance had been ToLower:ed would also be asserted as ok by BeLowerCased. So for instance, a silly example:

var test = "ABC123".ToLower();
test.Should().BeLowerCased(); // ==> true

Thanks for pointing me in the right direction regarding NotBeUpperCased

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improving Unit Tests with Fluent Assertions
BeLoweredCased() and BeUpperCased() will test if the SUT is comprised of all lower or upper case characters. Conversely, there are also 'Not' ...
Read more >
Strings
For asserting whether a string is null, empty, contains whitespace only, or is in upper/lower case, you have a wide range of methods...
Read more >
how to check if a string contains only lower case letters and ...
You can use isdigit() or islower() method to check string contains only numbers and lower case letters import string input_str=raw_input() ...
Read more >
Fluent Assertions: Fluently Assert the Result of .NET Tests
Numbers and special characters do not have casing, so BeUpperCased and BeLowerCased will always fail on a string that contains anything but ...
Read more >
Google | Screening - LeetCode Discuss
Problem: Given an input string, return an output string such that all the lower case characters should be sorted. Indices of non-lower case...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found