有没有办法决定 RhinoMocks 模拟何时开始录制? [英] Is there a way to decide when a RhinoMocks mock starts recording?

查看:48
本文介绍了有没有办法决定 RhinoMocks 模拟何时开始录制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,用RhinoMocks创建的mock对象在创建时直接进入录音状态,然后调用Replay()进入replay状态.我想手动决定模拟对象何时开始录制,或者能够暂停录制.这在 RhinoMocks 中可以实现吗?

As I understand it, a mock object created with RhinoMocks enter the recording state directly when it is created, and then you call Replay() to enter the replay state. I would like to manually decide when the mock object starts recording, or be able to pause the recording. Would that be possible in RhinoMocks?

谢谢/埃里克

推荐答案

Mock 处于记录或回放模式.他们不能处于无"模式.

Mocks are either in record or replay mode. They can't be in a "nothing" mode.

如果您不想使用 AAA 语法并且想要控制记录/重放状态,那么您必须在创建模拟后立即调用 mockRepository.Replay(mock) 方法来手动完成.

If you don't want to use the AAA syntax and you want to control the record/replay state then you'll have to do it manually by calling the mockRepository.Replay(mock) method immediately after creating the mock.

使用 mockRepository.BackToRecord(mock,option) 方法将模拟放回记录模式.使用 BackToRecordOptions.None 选项可防止清除您已设置的任何期望.

Use the mockRepository.BackToRecord(mock,option) method to put the mock back in record mode. Use the BackToRecordOptions.None option to prevent the clearing of any expectations you have already set.

这篇关于有没有办法决定 RhinoMocks 模拟何时开始录制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆