i wonder if it is possible to auto mock a container in MOQ without any additions to the MOQ lib. I am having problems finding a clean way to automock an IList.
Thanks in advance!
i wonder if it is possible to auto mock a container in MOQ without any additions to the MOQ lib. I am having problems finding a clean way to automock an IList.
Thanks in advance!
Answer to your question: No.
Do you really need to mock IList?
Mocks are typically used to:
You could for example mock a repository that access a database. Normally your tests would not mock a list but rather have a mocked object return a list with the data that you need for your test.
ie:
var aList = new List<int>() { 1, 2, 3, 4, 5 };
var mockService = new Mock<IMyService>();
mockService.Setup(mock => mock.GetFooList()).Returns(aList);
It might help clarify your question if you specify why you need to mock a container.
© 2022 - 2024 — McMap. All rights reserved.