本文介绍了如何用Rhino Mocks模拟IDbSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我根本无法正常工作。我在测试中得到了以下代码:

I can't get this working at all. I've got this code in my test:

MockRepository repository = new MockRepository();
IDbSet<SystemUser> userSet = repository.StrictMock<IDbSet<SystemUser>>();
Expect.Call(userSet.Any(u => u.Id == "UserName")).Return(true);
// More code follows

但是它在上轰炸StrictMock 行,出现错误:

But it bombs out on the StrictMock line with the error:

有什么想法吗?

谢谢!

推荐答案

您遇到了Rhino.Mocks(版本3.6.0.0)在通用方法约束下存在的已知问题。

You have encountered a known issue that Rhino.Mocks (version 3.6.0.0) has with generic method constraints.

'Create'方法:

The 'Create' method:

TDerivedEntity Create<TDerivedEntity>() where TDerivedEntity : class, TEntity

由于约束而无法正确生成,其中TDeriv edEntity:类,TEntity

此处有关于此错误的更多信息:

There is more information regarding the bug here : Can't get RhinoMocks to emit a mock that follows the generic type restriction rules

不幸的是,看来我们将不得不等待下一个Rhino.Mocks版本来解决此问题。

Unfortunately, it looks like we are going to have to wait for the next version of Rhino.Mocks to address the issue.

这篇关于如何用Rhino Mocks模拟IDbSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 10:49