- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试编写一个单元测试来比较两个数组。我已经定义了单元测试:
[DataTestMethod]
[DataRow(
new[] { "COM3", "COM1", "COM2" },
new[] { "COM1", "COM2", "COM3" }
)]
...
public void TestCOMPortSorting(string[] unorderedPorts, string[] expectedOrderedPorts)
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
new string[]
, 用这些数组创建一个数组,一切都没有运气。
最佳答案
对于如此复杂的数据,请改为使用 DynamicData
属性
This attribute allows to get the values of the parameters from a method or a property. The method or the property must return an
IEnumerable<object[]>
. Each row corresponds to the values of a test.
[DataTestMethod]
[DynamicData(nameof(TestDataMethod), DynamicDataSourceType.Method)]
public void TestCOMPortSorting(string[] unorderedPorts, string[] expectedOrderedPorts) {
//...
}
static IEnumerable<object[]> TestDataMethod() {
return new[] {
new []{ new[] { "COM3", "COM1", "COM2" }, new[] { "COM1", "COM2", "COM3" } } //a data row
};
}
关于c# - 如何提供两个数组作为 DataRow 参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57609039/
我有一个扩展DataRow的类: import org.jdesktop.dataset.DataRow; public class MainDataRow extends DataRow { p
查看下面的代码块, DataTable _table = new DataTable(); //1) Why I need to Convert DataRow again into DataRow
我的代码: DataRow[] row = ByTotalTemplate.Select("TEMPLATE_ID=" + DisTemplateID); 一行包含TEMPLATE_ID、MIN_AM
使用这段代码: OracleDataTable dt = PlatypusSchedData.GetAvailablePlatypi(); OracleDataTable outputDt = new
假设我从多个线程访问一个DataTable。如果我想访问特定行,我怀疑我需要锁定该操作(我可能对此有误,但至少我知道这样我是安全的): // this is a strongly-typed tabl
我收到这个错误 "Error 8 Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Coll
我有很多如下形式的代码: // assume that MyDataRow is a datarow from a typed dataset and has a property called So
在我的表中,有数据行注释,它存储为文本数据类型。 我有 Datarow idPersonalstamm,它存储为 int。 我的问题是,有时来自 Personalstamm 的数据会被复制到评论中。
我正在尝试将文本框中的新词添加到表格中: private void addAnswer_Click(object sender, EventArgs e) { // Get a new row
我的模块中有一个 cmdlet,它从数据库表中返回一组通用 DataRows,其名称由 -Name 指定。范围 # this returns a collection of datarows from
我在此代码行中得到一个空引用: **DataRow dr = tableSelectedItems.NewRow();** 我不知道为什么。谁能帮帮我吗?我的代码应该填写用户在数据列表中选择的书籍。
我尝试将值从自定义集合传递给 DataRow 类型变量,如下面的代码: GridHitInfo downHitInfo = null; DataRow row = gridView3.GetDataR
我正在尝试比较循环中的两个 DataRow。但是,以下 if 语句不会返回 true: if (dt1.Rows[0]["Name"] == dt2.Rows[b]["Name"]) { //
我在一个网站工作。我无法转换表格中行[""] 中的数值。我的代码是: public partial class bought : System.Web.UI.Page { protected
每当我在 MySql 中运行此查询时,它总是返回 3 行具有相同 ID,但记录不同的行,但在我的代码中,它只返回 1 行。 这是我的代码: public DataTable DBSelect(stri
我有以下问题。我将值作为 XML(如字符串)进行传递,并且不会为数字列传递默认值,例如 false 或 0。因此,我创建了一个字典,其中键是列名,值是传递的值。 这是我当前的代码 foreach (K
我正在尝试将 DataTable 中的所有 DateTime 值转换为字符串。这是我使用的方法: private static void ConvertDateTimesToStrings(DataT
我明白了: DataTable dtEntity = CreateDataTable(); drEntity = dtEntity.NewRow(); 然后我将数据添加到该行(或不添加)。一大堆代
我遇到了 DataRow 的问题,这让我很头疼。 使用 OleDbConnection 从 Excel 电子表格中读取数据行。 如果我尝试使用列名从 DataRow 中选择数据,即使那里有数据,它也会
我正在尝试编写一个单元测试来比较两个数组。我已经定义了单元测试: [DataTestMethod] [DataRow( new[] { "COM3", "COM1", "COM2" },
我是一名优秀的程序员,十分优秀!