我在编写一些测试时想知道在使用 xUnit 测试时是否可以使用 @microsoft 声明的 string.isempty。 (见下文)
我是一名编程学生,我的老师建议尽可能使用@microsofts 已经定义的方法和常量。
我试过了,但似乎没有用,所以我想我可能做错了什么。
[Theory]
[InlineData(string.Empty)]
[InlineData(null)]
[InlineData(" ")]
[InlineData(" ")]
[InlineData(" someRandomText")]
// ...
public void SetEmailaddress_WrongEmail_IllegalArgumentException(string data) // type of method that is being test, what kind of test, the expected outcome
{
//Assert
Assert.Throws<ArgumentException>(() => _l.Emailaddress = data);
}
提前致谢!
问候
最佳答案
它与测试无关,与属性有关。属性必须是编译时常量。
你可以去this找出为什么 string.empty
与 ""
关于c# - 使用inlinedata时是否可以使用string.empty?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55710151/