Rhino 模拟 AAA 快速入门?
我一直在寻找一些有关使用 Rhino Mocks 3.5+ 和 AAA 语法的不错的信息。我发现很多博客混合了新旧内容,这似乎使得弄清楚如何使用它变得更加困难。
如果有一个像早期版本那样的 Rhino Mocks AAA 备忘单,那就太好了。您是否需要了解有关旧版本 Rhino 的所有信息才能实际使用新版本?我确信如果我是专家,我会喜欢 Rhino 的所有功能,但现在我只是沉浸在信息中。任何指示或良好的链接将不胜感激!
I've been looking around for some decent information on using Rhino Mocks 3.5+ with the AAA syntax. I find a lot of blogs that have a mix of things from the old and new which seem to make it more difficult to figure out how to use it.
Would would be great would be if there were a Rhino Mocks AAA Cheat Sheet like was done for an earlier version. Is it required that you know everything about the older versions of Rhino to actually use the newer version? I'm sure if I were an expert that I would love all the capabilities in Rhino, but for now I'm just swimming in information. Any pointers or good links would be totally appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我写了一个 Rhino Mocks Arrange / Act / Assert (AAA) Syntax Quick参考。它包含从 Ayende 网站 收集的有关此语法样式的浓缩信息,以及其他几个博客。
I have written a Rhino Mocks Arrange / Act / Assert (AAA) Syntax Quick Reference. It contains condensed information about this syntax style collected from Ayende's web site and several other blogs.
我假设您熟悉官方文档,我认为这相当不错。
我的建议是尝试使用Rhino,当你遇到一些更具体的问题时,在SO或其他地方寻找解决方案。我认为没有针对 Rhino 模拟的全面备忘单。我想你会更幸运地问“我怎样才能使用Rhino Mocks 做到这一点和那个”
编辑:
那么,当目标为 AAA 时,您不需要使用录制/播放。
AAA涉及三个步骤:
例如,模拟类的行为
。
Act,代表执行测试
和Assert,代表veryfing
结果
。
也许上面的例子不是最好的,但可能会让你找到正确的方向。
I assume that you're familiar with official documentation, which is quite good in my opinion.
My suggestion is to try to use Rhino, and when you encounter some more specific problem search for solution wither on SO or somewhere else. I don't think that there is a comprehensive cheat sheet for Rhino mocks. I guess you'll have more luck asking "How can I do this and that using Rhino Mocks"
Edit:
Well, you don't need to use Record/Playback when targeting AAA.
There are three steps involved in AAA:
the behavior of mocked class, for example
.
Act, which stands for executing the tests
And Assert, which stands for veryfing
the results
.
Perhaps the above examples aren't the best, but might get you into right direction.
首先确保您了解 AAA 中每个 A 的含义。您可能知道,但为了答案的完整性,我将包括我的工作定义:
我喜欢在测试代码中添加注释,以提醒我考虑每一件事情。一个例子可能有助于澄清:假设我有一个服务层类,它使用两个提供者层类,一个来自“旧”系统,一个来自“新”系统;我正在测试将旧事物复制到新系统的方法对于找到的每个旧事物都会调用一次“CreateThing”方法。
First make sure you know what you mean for each A in AAA. You may know but I'll include my working definitions for completeness of the answer:
I like to put comments in my test code to remind me to think about each of those things. An example may help clarify: Suppose I have a service layer class which uses two provider layer classes, one from an "old" system and one from a "new" system; I am testing that the method which copies old things to the new system calls the "CreateThing" method one time for each old thing found.
您可能想从Ayende 在 AAA 上的原始帖子开始,然后看看 Ben Hall 关于 AAA 的精彩博客文章。比您可以使用其他答案中提到的所有完整参考文献......
You'd probably want to start at Ayende's original post on AAA, and than take a look at Ben Hall's nice blog post about AAA. Than you could use all the complete references mentioned in other answers...