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

送分小仙女□ 提交于 2019-12-24 03:07:05

问题


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:


Assert on the outcome of string.IsNullOrEmpty()



来源:https://stackoverflow.com/questions/49183102/c-sharp-in-my-unit-test-i-want-to-see-if-it-is-null-or-an-empty-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!