这是一个在我看来应该通过但不是的测试。打开通用接口类型的开放实现不等于接口类型?
[TestMethod]
public void can_get_open_generic_interface_off_of_implementor()
{
typeof(OpenGenericWithOpenService<>).GetInterfaces().First()
.ShouldEqual(typeof(IGenericService<>));
}
public interface IGenericService<T> { }
public class OpenGenericWithOpenService<T> : IGenericService<T> { }
- 为什么会出现这种不通过?
- 鉴于
Type t = typeof(OpenGenericWithOpenService<>)
如何获得typeof(IGenericService <>)?
我一般很好奇,但是如果你想知道我在做什么,我正在编写一个Structuremap约定,将实现的所有接口转发给实现(作为单例)。
破解问题。调查:) – 2010-04-20 20:25:27
如果你真的想让测试通过,你可以比较GUID。 – 2010-04-20 20:33:56