Hi
I see two options here:
If the list is used in the code via property or method you can mock it to
always return your fake list.
the example below assumes that you have public property CustomList.GetList
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
CustomList mock = new CustomList();
recorder.ExpectAndReturn(mock.GetList, fakeList).RepeatAlways();
}
If you are not using property or method the other option is to mock the field.
Example:
public class CustomList
{
private List<int> _list = new List<int>();
public void Fill()
{
// fill the list ...
}
}
[Test]
public void Test()
{
Mock mockCustomList = MockManager.Mock<CustomList>();
List<int> fakeList = new List<int>();
fakeList.Add(1);
fakeList.Add(2);
fakeList.Add(3);
mockCustomList.AssignField("_list", fakeList);
}
:arrow: I'm using reflective mocks in order the get access to a private field.
Hope it helps. Please tell me if you have more questions.