c# - 你如何使用 String.IsNullOrEmpty 单元测试代码?

标签 c# unit-testing

您是否编写了两个单元测试?一个值是 Null,一个值是 string.Empty?与 string.IsNullOrWhiteSpace() 类似吗?

最佳答案

是的,您通常希望测试所有可能的输入类别(null、空、空白、非空白)是否获得正确的输出。

这意味着测试 String.IsNullOrEmpty() 的两个备选方案和 String.IsNullOrWhitespace() 的所有三个备选方案。

关于c# - 你如何使用 String.IsNullOrEmpty 单元测试代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27245353/

相关文章:

C# 如何在文本文件中写入多行?

c# - 如何用连字符实现 asp.net mvc Action 名称?

python - 在 Django 中测试特定的应用程序

asp.net - 将单元测试添加到现有的 ASP.NET Web 表单应用程序

angular - 错误 : StaticInjectorError(DynamicTestModule)[NotificationsComponent

c# - 将 BitmapImage 字节数组转换为 Image 字节数组 (WinRT -> WinForms)

c# - 如何快速将数组归零?

c# - 设置UIaccess更改ShowDialog的行为

c# - 我如何使用 xUnit Assert.RaisesAny?

visual-studio - VS08 中无法加载测试项目