【发布时间】:2016-07-25 13:51:14
【问题描述】:
我在使用 xUnit 时尝试将变量用作 InlineData。
看起来像这样:
static string home = "test";
[Theory]
[InlineData(home)]
public void AddTest(string location)
{
Assert.True(LocationIs(location));
}
但我收到错误:“属性参数必须是属性参数类型的常量表达式、typeof 表达式或数组创建表达式”
我有什么办法可以做我正在尝试的事情吗?还是我只需要对内联数据进行硬编码。
【问题讨论】: