旧数据库、Fluent NHibernate 和测试我的映射

发布于 2024-08-24 23:10:59 字数 489 浏览 4 评论 0原文

正如帖子标题所暗示的那样,我有一个遗留数据库(不确定这是否重要),我正在使用 Fluent NHibernate,并且我正在尝试使用 流畅的 NHibernate PersistenceSpecification 类

我的问题实际上是一个流程问题,我现在想在使用内置单元测试框架在 Visual Studio 中本地构建时测试这些。显然,这意味着(我认为)我将需要一个数据库。有哪些选项可以将其纳入构建中?如果我使用内存数据库,NHibernate 或 Fluent NHibernate 是否有某种机制可以从目标数据库中获取数据库模式,或者内存数据库可以做到这一点?我是否需要手动获取架构以提供给内存数据库?

理想情况下,我希望将这种设置设置为其他开发人员实际上不必考虑它,除非他们因为测试未通过而破坏构建。

As the post title implies, I have a legacy database (not sure if that matters), I'm using Fluent NHibernate and I'm attempting to test my mappings using the Fluent NHibernate PersistenceSpecification class.

My question is really a process one, I want to test these when I build locally in Visual Studio using the built in Unit Testing framework for now. Obviously this implies (I think) that I'm going to need a database. What are some options for getting this into the build? If I use an in memory database does NHibernate or Fluent NHibernate have some some mechanism for sucking the database schema from a target database or maybe the in memory database can do this? Will I need to manually get the schema to feed to an in memory database?

Ideally I would like to get this this setup to where the other developers don't really have to think about it other than when they break the build because the tests don't pass.

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

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

发布评论

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

评论(1

就像说晚安 2024-08-31 23:10:59

NHibernate 无法重新创建数据库的架构,并且因为它是一个遗留系统,您可能无法从 NH 生成架构。最好的方法是在事务中进行集成测试,并在完成后将其回滚。我们针对开发和测试数据库运行集成测试,这些数据库定期从实时系统刷新。

NHibernate isn't able to re-create your database's schema and because it's a legacy system you likely won't be able to generate the schema from NH. The best approach is to do your integration tests in transactions and roll them back when complete. We run integration tests against our dev and test databases which are periodically refreshed from the live system.

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