Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法将动态表实体转换为断言中的System.threading实体_C#_Xunit - Fatal编程技术网

C# 无法将动态表实体转换为断言中的System.threading实体

C# 无法将动态表实体转换为断言中的System.threading实体,c#,xunit,C#,Xunit,我试图在我的函数上实现一个断言,该函数在单独的项目中调用。调用的函数如下所示: public async Task<List<DynamicTableEntity>> PopulateTable( string documentId, IEnumerable<string> lines, JsonSchema schema, string type, string subType,

我试图在我的函数上实现一个断言,该函数在单独的项目中调用。调用的函数如下所示:

public async Task<List<DynamicTableEntity>> PopulateTable(
        string documentId,
        IEnumerable<string> lines,
        JsonSchema schema,
        string type,
        string subType,
        string format,
        bool upsert ){var tableEntries = new List<DynamicTableEntity>( tableData.Count );
.....
return tableEntries;  }
public异步任务PopulateTable(
字符串documentId,
数不清的线,
JsonSchema模式,
字符串类型,
字符串子类型,
字符串格式,
bool upsert){var tableEntries=新列表(tableData.Count);
.....
返回tableEntries;}
在某些情况下,它会抛出一个异常,我想用Xunit框架测试一下。我的TDD代码如下所示:

 public async Task UploadAndSchemaCheckOnMissingKey()
 {      
    var table = await _tableStore.PopulateTable(null, lines, schema, "tableOutput", null, "test", false);
       
    await Assert.ThrowsAsync<ArgumentException>(table);
 }
Func<Task> table = async() => await _tableStore.PopulateTable(null, lines, schema, "tableOutput", null, "test", false);
var ex = await Assert.ThrowsAsync<FormatException>(table);
Assert.Contains("expected error message", ex.Message);
public async Task UploadAndSchemaCheckOnMissingKey()
{      
var table=await _tableStore.PopulateTable(null,行,模式,“tableOutput”,null,“test”,false);
等待Assert.ThrowsAsync(表);
}
我得到的错误是无法将
System.Collection.generic.List转换为System.Func


当抛出异常时,我应该如何处理我的测试用例通过的问题?

您可以这样使用它:

 public async Task UploadAndSchemaCheckOnMissingKey()
 {      
    var table = await _tableStore.PopulateTable(null, lines, schema, "tableOutput", null, "test", false);
       
    await Assert.ThrowsAsync<ArgumentException>(table);
 }
Func<Task> table = async() => await _tableStore.PopulateTable(null, lines, schema, "tableOutput", null, "test", false);
var ex = await Assert.ThrowsAsync<FormatException>(table);
Assert.Contains("expected error message", ex.Message);
Func table=async();
var ex=await Assert.ThrowsAsync(表);
Assert.Contains(“预期的错误消息”,例如消息);