私はこのリストをモックしようとしています:
private readonly IList<MyClass> myList = new List<MyClass>();
これを使用して(ここに見られるように):
IList<MyClass> mockList = Builder<MyClass>.CreateListOfSize(5).Build();
mockObj.SetupGet<IEnumerable<MyClass>>(o => o.myList).Returns(stakeHoldersList);
ただし、実行時に InvalidCastException が発生します。
Unable to cast object of type 'System.Collections.Generic.List`1[MyClass]' to
type 'System.Collections.ObjectModel.ReadOnlyCollection`1[MyClass]'.
私は何を間違っていますか?