如何在下面的代码中返回IEnumerable<T>
类型的expected
?
public List<object> expected = new List<object>();
public IEnumerable<T> SqlQuery<T>(string sql)
{
// Return expected as IEnumerable<T>
}
这是一个专门为单元测试而创建的类,用于模拟Entity Framework中的SqlQuery<T>
方法。我们可以提前设置预期结果,并使其返回我们所期望的结果。
expected
是一个字段而不是类型为List<T>
的局部变量? - Michael Liuexpected
序列,其中每个元素都会进行类型转换为类型T
。 - Alexander DerckList<object>
? - David