RhinoMocks 和泛型的问题
这是我的测试代码:
var container = MockRepository.GenerateMock<UnityContainer>();
container.Expect(e => e.RegisterType<IEventAggregator, EventAggregator>(
Arg<ContainerControlledLifetimeManager>.Is.Anything));
基本上,我将断言采用 IUnityContainer 接口的类以预期的方式设置容器。
问题是 RhinoMocks 认为我正在尝试在容器上调用此方法:
RegisterType(Type from, Type to, String name,
LifetimeManager lifetimeManager, InjectionMember[] injectionMembers)
但是如果我在 Visual Studio 中“转到定义”,它会转到正确的位置:
RegisterType<TFrom, TTo>(LifetimeManager lifetimeManager,
params InjectionMember[] injectionMembers)
我需要做什么才能正确模拟此方法?
谢谢, 贾森
Here's my test code:
var container = MockRepository.GenerateMock<UnityContainer>();
container.Expect(e => e.RegisterType<IEventAggregator, EventAggregator>(
Arg<ContainerControlledLifetimeManager>.Is.Anything));
Basically I'm going to assert that a class that takes a IUnityContainer interface sets up the container in an expected way.
The problem is that RhinoMocks thinks I'm trying to call this method on the container:
RegisterType(Type from, Type to, String name,
LifetimeManager lifetimeManager, InjectionMember[] injectionMembers)
But if I "go to definition" in Visual Studio, it goes to the right place:
RegisterType<TFrom, TTo>(LifetimeManager lifetimeManager,
params InjectionMember[] injectionMembers)
What's the magic sauce I need to do to get this mocked correctly?
Thanks,
Jason
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
RegisterType 是 UnityContainerExtensions 的扩展。难怪我无法嘲笑它!
RegisterType is an extension from UnityContainerExtensions. No wonder I couldn't mock it!