我想在编写一些测试时,如果可以在使用xUnit测试时使用@microsoft声明的string.isempty。 (见下文)
我是一名编程学生,我的老师建议使用@microsofts已经定义的方法和consts尽可能。
我试过了,但它似乎没有用,所以我想我可能做错了什么。
[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);
}
提前致谢!
Greetingz
它与测试无关,与属性有关。属性必须是编译时常量。
你可以去this问题找出为什么string.empty
不被视为常数vs ""