Moq 和 Rhino.mocks 的功能是什么?

发布于 2024-07-15 08:32:33 字数 432 浏览 13 评论 0原文

我找不到 Moq 和 Rhino 的具体功能比较。 所有的问题都是“你更喜欢哪个以及为什么”,或者“这是你如何在犀牛中进行简单的模拟以及如何在最小起订量中完成”。

我在任何地方都找不到深入的比较。 我知道语法差异,我不是在寻找答案。 我正在寻找能力比较。 例如:

  • Rhino 有 Expect.On() 用于线程 嘲笑。 Moq 可以做到这一点吗?

  • 多重模拟怎么样 (实现多个接口 与一个模拟)。 Moq 可以做到这一点吗?

  • 我相信 Moq 现在可以模拟受保护的成员。 Rhino 可以做到这一点吗?

编辑:我最终也研究了其他一些 .Net 框架。

I cannot find a specific feature-by-feature comparison of Moq and Rhino. All the questions are "which do you like better and why", or "here's how you do a simple mock in rhino and how it's done in moq".

I cannot find a deep comparison anywhere. I'm aware of the syntax differences, I'm not looking for answers about that. I am looking for a capability comparison. For example:

  • Rhino has Expect.On() for threaded
    mocking. Can Moq do this?

  • What about Multi-mocking
    (implementing multiple interfaces
    with one mock). Can Moq do this?

  • I believe Moq can now mock Protected members. Can Rhino do this?

Edit: I ended up looking at some of the other .Net frameworks as well.

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

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

发布评论

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

评论(5

猫腻 2024-07-22 08:32:33

感谢那些在过去几周做出回应的人。 我最终写了一篇关于我的发现的博客文章,因为我必须进行大量的挖掘,所以我似乎最好总结一下它们,希望能帮助其他人。 我发布的图表组织了我的发现:

alt text

我在博客文章中提到的一个警告是,该图表对于检查功能很有用,但大多数框架的真正优势是它们独特的功能。 我最终选择了 Moq,因为 API 易于使用。 此外,所有信息都可能存在错误和更改 - 如果您不同意图表上的某些内容,请发表评论。

Thanks to those that responded over the last few weeks. I ended up writing a blog post about my findings, since I had to do so much digging that it seemed like I might as well summarize them in the hopes of helping others. The chart I posted organizes my findings:

alt text

One caveat, which I touched on in the blog post, is that the chart is useful for checking the capabilities, but the real advantages to most frameworks are their unique features. I chose Moq in the end because of the easy to use API. Also, all the information is subject to errors and change - if you disagree with something on the chart, please post a comment.

枫以 2024-07-22 08:32:33

无论如何,我都不是专家,但我相信 Rhino 添加了一些 Moq 语法,因此学习曲线已降低到您对 MoQ 的期望。 我对两者进行了测试,其中一些语法几乎相同。 我最初打算选择最小起订量,因为它更容易,但后来我的朋友向我展示了最新的更新以及它们的相似之处。 只是让你知道。

I'm not an expert by any means, but I believe the Rhino added some of the Moq syntax so that the learning curve has been reduced to what you'd expect with MoQ. I worked with both with testing and some of the syntax was almost identical. I was initially going to go with MoQ as it was easier, but then my bud showed me the latest updates and how similar they were. Just letting ya know.

迷爱 2024-07-22 08:32:33

Rhino 有 GetArgumentsForCallsMadeOn(),在某些情况下,IMO 可以更轻松地验证参数。

Rhino has GetArgumentsForCallsMadeOn() which IMO makes it easier to verify arguments in some cases.

魂归处 2024-07-22 08:32:33

为了完整起见,我将指出 CodePlex 上现在有 NMock3。 它可以轻松地从 NMock2 迁移,只需将 NMock2.dll 的引用替换为 NMock3.dll 的引用即可。 它增加了类型安全性和对重构的支持。

Just for completeness I will note that there is now NMock3 on CodePlex. It has easy migration from NMock2, just replace the reference to NMock2.dll with a reference to NMock3.dll. It adds type safety and support for refactoring.

空城仅有旧梦在 2024-07-22 08:32:33

我可能会在其中添加“行为验证”。 这似乎是 Moq 的最大限制,Rhino(不确定其他)对此没有问题。

I might add "Behavior Verification" into these. That seems to be Moq's biggest limitation, which Rhino (not sure about others) has no problem with.

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