【发布时间】:2016-01-26 10:42:44
【问题描述】:
有谁知道我可以如何参数化以下内容:
[Test]
void SelectTest(Expression<Func<MyType, bool>> where)
{
try
{
using (var db = new DataConnection("MyData"))
{
where = e => e.Status == Status.New;
var data = db.GetTable<MyType>()
.(where.Compile())
.Select(e => e);
Assert.IsNotEmpty(data);
}
}
catch (Exception)
{
Assert.False(true);
}
}
我尝试添加这样的测试用例:
[TestCase(e => e.Status == Status.New)]
但我收到以下错误:
表达式不能包含匿名方法或 lambda 表达式。
我错过了什么?
(我使用的是 linq2db 和 nunit)
【问题讨论】:
标签: c# linq unit-testing nunit