C# in my unit test i want to see if it is null or an empty string

6.9k Views Asked by At

I'm using Machine spec / Shouldly and testing a mapping profile (mundane work). The mapping expectations are sometimes inconsistent. Sometimes I am seeing an "" explicit empty string get returned and sometimes it's a null value. Since we're mapping to a spreadsheet it doesn't matter on that front but it gets a little annoying when asserting.

Is there a way in Machine spec to do something like assertionValue.ShouldEqual(null || "") ?

1

There are 1 best solutions below

3
raouf ben hassine On

Assert on the outcome of string.IsNullOrEmpty()