如何正确测试持久层?

发布于 2024-08-17 10:08:34 字数 222 浏览 3 评论 0原文

我读过《NHibernate in Action》一书,里面谈到了测试持久层/数据抽象层。您可以通过两种方式进行测试。 映射测试持久性逻辑测试。根据该书,测试映射意味着实体已正确加载和保存。

但是更新和删除又如何呢?

现在我使用 Fluent NHibernate,这也只是测试加载和保存。

如何正确测试持久层?

I read the Book NHibernate in Action and there it is speaking about testing the persistence layer/data abstraction layer. You can test two ways. The mapping-test and the persistence logic-test. Accoring to the book testing the mapping means that entities are correctly loaded and saved.

But what's about update's and delete's?

By now I use Fluent NHibernate and this is also only testing for loading and saving.

How do I test a persistence layer correctly?

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

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

发布评论

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

评论(2

把时间冻结 2024-08-24 10:08:34

在过去的项目中,我编写了 NUnit 测试,用于针对 SQLite DB 执行更新和删除 NHibernate 逻辑。

不过,我并不提倡这是正确的做事方式。如果 NHibernate 成功执行保存和加载,它就能够更新和删除,我对此感到相当满意。

On past projects, I've written NUnit tests that exercised the update and delete NHibernate logic against a SQLite DB.

I'm not advocating this as the correct way to do things though. I'd be reasonably comfortable that if NHibernate is successfully performing saves and loads, it'll be able to update and delete.

赤濁 2024-08-24 10:08:34

可以在这里找到单元测试模式的良好指南:
http://www.codeproject.com/KB/architecture/autp5.aspx

A good guide to unit test patterns can be found here:
http://www.codeproject.com/KB/architecture/autp5.aspx

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