Should().NotBeNullOrWhiteSpace() ?
See original GitHub issueHi!
The Strings page at https://fluentassertions.com/strings says there’s a method :
theString.Should().NotBeNullOrWhiteSpace();
…but I am getting : ‘ObjectAssertions’ does not contain a definition for ‘NotBeNullOrWhiteSpace’ …
Oh wait, I am doing this:
Result.Should().NotBeNull().And.Should().NotBeNullOrWhiteSpace();
That doesn’t work, but this does:
Result.Should().NotBeNullOrWhiteSpace();
Why is there a difference there?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
C# item isn't in List, and not null or whitespace
Hint: look at your while condition - it says "While "the folder name isn't empty, or the folder name is empty". How could...
Read more >string.Should().NotBeNullOrWhitespace() · Issue #7
A NullOrEmpty already exists, but not one for whitespace. ... This behavior would seem to be provided by the existing NotBeBlank() method.
Read more >String.IsNullOrWhiteSpace(String) Method (System)
Indicates whether a specified string is null, empty, or consists only of white-space characters.
Read more >Why is there no string type that enforces non-null ...
My code is littered with checks for empty strings, null strings and whitespace-only strings. I would guess that in most cases, a developer ......
Read more >How to check if a string has only whitespace or is empty in C#
In C#, the IsNullOrEmpty() method can be used to check if a string is empty or null . But if we want to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The misleading/confusing error message with
ObjectAssertions
is becauseAnd
return anAndConstraint
and thenShould
resolved toShould(this object)
that returns anObjectAssertions
which, as the messages points out, does not contain anyNotBeNullOrWhiteSpace
method.It’s a string yes, like this:
But when I remove the extra Should() it works nicely!