【发布时间】:2017-04-24 07:01:47
【问题描述】:
有了这个接口,我如何使用 moq 模拟这个对象?
public interface IMyCollection : IEnumerable<IMyObject>
{
int Count { get; }
IMyObject this[int index] { get; }
}
我明白了:
无法将表达式类型 IEnumerable 转换为 IMyCollection
【问题讨论】:
-
为什么不直接做一个
IList<MyObject>? -
@ShaneKm 请注意,从 .NET 4.5 开始,.NET
IReadonlyList<T>内置了一个类型,可以执行您尝试执行的确切合同,并且您可以从中受益已经被应用于像List<T>这样的内置类型
标签: c# asp.net unit-testing moq