Subsonic 3.0 TestRepository“查找”不工作

发布于 2024-09-25 09:46:16 字数 1302 浏览 4 评论 0原文

使用 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 模板中的相等比较,如下所述:修复问题使用 SubSonic 3 的 TestRepository 但这没有帮助。

Using Subsonic 3, I have a simple class called "ConferenceRepository" that has a method that returns a bunch of conferences based on their status. I am testing this using SubSonic's built in support for testing. My setup of the repo looks like this:

// 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);

And then my Repo class eventually executes this line, using Find():

return Conference.Find(c => c.Approved).ToList(); 

Trouble is, this always returns all the records (9). I've tried different find criteria, to no avail.

Anyone know what the issue is? I've tried fixing equality comparison in the tt templates as described here: Fixes for problems with SubSonic 3's TestRepository but that doesn't help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦断已成空 2024-10-02 09:46:16

因此从 .Find 更改为...

return Conference.All().Where(c => c.Approved == true).ToList(); 

解决了这个问题。

So changing from .Find to...

return Conference.All().Where(c => c.Approved == true).ToList(); 

Solves it.

海风掠过北极光 2024-10-02 09:46:16

应该没有什么区别,但你尝试过吗:

return Conference.Find(c => c.Approved == true).ToList(); 

Shouldn't make any difference, but did you tried:

return Conference.Find(c => c.Approved == true).ToList(); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文