Operators are a bit confusing in NUnit. Personally I don't fully understand how they work.
I've seen multiple times that constraint Is.Not.Null.Or.Empty is used to validate that string is not empty, which is wrong - it should be either Is.Not.Null.And.Not.Empty, or Is.Not.Null & Is.Not.Empty, or !Is.Null.Or.Empty.
But it might be missed because Not operator precedence is not obvious (one of the reasons I prefer using &/| operators instead of .And/.Or).
Since Is.Not.Null.Or.Empty constraint makes no sense (empty string or collection is always not null), I suggest always marking it as warning.
Any ideas for other commonly misused constraints?
Operators are a bit confusing in NUnit. Personally I don't fully understand how they work.
I've seen multiple times that constraint
Is.Not.Null.Or.Emptyis used to validate that string is not empty, which is wrong - it should be eitherIs.Not.Null.And.Not.Empty, orIs.Not.Null & Is.Not.Empty, or!Is.Null.Or.Empty.But it might be missed because
Notoperator precedence is not obvious (one of the reasons I prefer using&/|operators instead of.And/.Or).Since
Is.Not.Null.Or.Emptyconstraint makes no sense (empty string or collection is always not null), I suggest always marking it as warning.Any ideas for other commonly misused constraints?