RhinoMocks - 模拟具体类型 - 运行构造函数
我有以下行,尝试创建具体类型的模拟:
AddPropPersonalCOI = MockRepository.GenerateMock<SomeType>(ObjectFactory.GetInstance<paramType1>(), ObjectFactory.GetInstance<paramType2>());
Assert.IsNotNull(AddPropPersonalCOI.view);
我实际上已经进入了有问题的构造函数,看着它执行,看着视图属性从传递到构造函数的值分配(我验证了不为空),但断言失败。
是的,视图是虚拟的。
有人知道我做错了什么吗?
I've got the following line, attempting to create a mock of a concrete type:
AddPropPersonalCOI = MockRepository.GenerateMock<SomeType>(ObjectFactory.GetInstance<paramType1>(), ObjectFactory.GetInstance<paramType2>());
Assert.IsNotNull(AddPropPersonalCOI.view);
I've actually stepped into the constructor in question, watched it execute, watched the view property get assigned from the value passed into the constructor (which I verified were not null), and yet the assert fails.
And yes, view is virtual
.
Anyone know what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
view
是虚拟的,您需要先为其设置一个期望,然后才能使用它。当您在期望模式下调用方法和属性时,Rhino Mocks 会为您提供null
值。If
view
is virtual, you'll need to set an expectation for it before you can use it. Rhino Mocks gives younull
values when you call methods and properties in expectations mode.