Entity Framework 4 的 Fluent 映射验证

发布于 2024-10-10 05:25:27 字数 889 浏览 3 评论 0 原文

注意:这是我之前的问题的后续问题。< /em>

灵感来自 在这篇博文中,我正在尝试构建一种流畅的方法来测试我的 EF4 仅代码映射。但是,我几乎立即陷入困境......

为了能够实现这一点,我还需要实现 CheckProperty 方法,并且我非常不确定如何将参数保存在 >PersistenceSpecification 类,以及如何在 VerifyTheMappings 中使用它们。

另外,我想为这个类编写测试,但我完全不确定如何实现这一点。我要测试什么?又如何呢?

任何帮助表示赞赏。

更新:我查看了 Fluent NHibernate 源代码中的实现,看起来只需获取源代码并将其适应实体框架就很容易了。但是,我在 部分的信息。 txt" rel="nofollow noreferrer">BSD 许可证。将他们的代码复制粘贴到我的项目中,并更改我想要的任何内容以满足我的需求,对于非商业私人或开源项目是否合法?它会用于商业项目吗?

Note: This is a follow-up question for this previous question of mine.

Inspired by this blog post, I'm trying to construct a fluent way to test my EF4 Code-Only mappings. However, I'm stuck almost instantly...

To be able to implement this, I also need to implement the CheckProperty method, and I'm quite unsure on how to save the parameters in the PersistenceSpecification class, and how to use them in VerifyTheMappings.

Also, I'd like to write tests for this class, but I'm not at all sure on how to accomplish that. What do I test? And how?

Any help is appreciated.

Update: I've taken a look at the implementation in Fluent NHibernate's source code, and it seems like it would be quite easy to just take the source and adapt it to Entity Framework. However, I can't find anything about modifying and using parts of the source in the BSD licence. Would copy-pasting their code into my project, and changing whatever I want to suit my needs, be legal for non-commercial private or open source projects? Would it be for commercial projects?

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

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

发布评论

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

评论(2

二手情话 2024-10-17 05:25:27

我本来打算建议看看 FluentNH 如何做到这一点,直到我收到您的更新。不管怎样,你已经在研究这种方法了。

至于您关于 BSD 许可证的问题部分,我想说许可证的相关部分是这样的:无论是否经过修改,都允许以源代码和二进制形式重新分发和使用,前提是满足以下条件满足:[条件如下]

根据我对该行的阅读,您可以根据需要修改(包括删除与您的用例不相关的任何代码)代码,并重新分发它,只要您满足作者的条件。

由于对于如何使用或重新分发代码或二进制文件没有任何限制,因此您可以对任何和所有应用程序自由地按照自己的意愿进行操作。

此处这里是通俗易懂的许可证描述。

I was going to suggest looking at how FluentNH does this, until I got to your update. Anyway, you're already investigating that approach.

As to the portion of your question regarding the BSD license, I'd say the relevant part of the license is this: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: [conditions follow].

From my reading of that line, you can modify (which would include the removal of any code not relevant to your use cases) the code however you wish, and redistribute it as long as you meet the author's conditions.

Since there are no qualifications on how you may use or redistribute the code or binaries, then you are free to do that however you wish, for any and all applications.

Here and here are descriptions of the license in layman's terms.

指尖微凉心微凉 2024-10-17 05:25:27

我总是为每个实体编写一组简单的集成测试。测试包括持久化、选择、更新和删除实体。我认为没有更好、更简单的方法来测试模型的映射和其他功能(例如级联删除)。

I'm always writing simple set of integration tests for each entity. Tests are persisting, selecting, updating and deleting entity. I thing there is no better and easier way to test your mapping and other features of the model (like cascade deletes).

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