使用Subsonic 3,我有一个名为“ConferenceRepository”的简单类,它有一个根据状态返回一堆会议的方法。我正在使用SubSonic内置的测试支持对此进行测试。我对回购的设置如下:
// 2 Approved, 4 pending, 3 rejected
var data = new List<Conference>
{
new Conference {Approved = true, Rejected = false},
new Conference {Approved = true, Rejected = false},
new Conference {Approved = false, Rejected = false},
new Conference {Approved = false, Rejected = false},
new Conference {Approved = false, Rejected = false},
new Conference {Approved = false, Rejected = false},
new Conference {Approved = false, Rejected = true},
new Conference {Approved = false, Rejected = true},
new Conference {Approved = false, Rejected = true}
};
Conference.ResetTestRepo();
Conference.Setup(data);
然后我的Repo类最终使用Find():
执行此行return Conference.Find(c => c.Approved).ToList();
麻烦的是,这总是返回所有记录(9)。我尝试了不同的查找标准,但无济于事。
任何人都知道这是什么问题?我已尝试在tt模板中修复等式比较,如下所述:Fixes for problems with SubSonic 3's TestRepository但这没有帮助。
答案 0 :(得分:1)
从.Find变为......
return Conference.All().Where(c => c.Approved == true).ToList();
解决它。
答案 1 :(得分:0)
不应该有任何区别,但你做过尝试:
return Conference.Find(c => c.Approved == true).ToList();