var itemMock = new Mock<IMyObject>();
var items = new List<IMyObject> { itemMock.Object };
var mock = new Mock<IMyCollection>();
mock.Setup(m => m.Count).Returns(() => items.Count);
mock.Setup(m => m[It.IsAny<int>()]).Returns<int>(i => items.ElementAt(i));
mock.Setup(m => m.GetEnumerator()).Returns(() => items.GetEnumerator());
The layout will use the specific Listto wrap and identify the desired behavior for the test.
Nkosi source
share