Quantcast
Channel: Fluent Assertions
Viewing all articles
Browse latest Browse all 1402

New Post: Method proposal: str.Should().BeBlank()

$
0
0

My idea is to call a string "blank" when it is null or empty or whitespace-only.

Microsoft in .Net 4 came up with the name IsNullOrWhiteSpace but it's too long to my taste so I use alias "IsBlank".

In the code I write now I never check strings separately for null or empty or whitespace. I call this class of strings "blank" because it is not "visible".

Usually when I get a blank string I don't do any processing on it regardless whether it is null, empty or whitespace-only.

Hence in my unit tests I just check if a string is blank or non-blank.

 

I would prefer IsBlank to capture null, empty and whitespace-only strings.

This way IsNull and IsEmpty are finer-grained "subset" methods of IsBlank and they all have their own use.


Viewing all articles
Browse latest Browse all 1402

Trending Articles