chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
I think it would be useful if we can generate a fake list straightaway from typemock, something like

Isolate.Fake.GenerateFakeList<T>(int numElement);


The code implementation would be something like this:


        public static List<T> GenerateFakeList<T>(int numElement)
        {
            var objList = new List<T>();
            for (int i = 0; i < numElement; i++)
            {
                objList.Add(Isolate.Fake.Instance<T>());
            }

            return objList;
        }

________
Hawaii Dispensaries
asked by nsoonhui (59.1k points)

2 Answers

0 votes
Hi Soon Hui,

That's a really nice idea! I'll put it in our backlog. Did you know that setting behavior on a chain with a list index item causes similar behavior?
This code:
Isolate.WhenCalled(() => x.List[3].Name).WillReturn("Name");

Will return a list with 4 items, the first 3 are recursive fakes according to the list item type, and the 4th is a recursive fake with specific behavior defined for the Name property. Does this help?

Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Hi Soon Hui,

That's a really nice idea! I'll put it in our backlog. Did you know that setting behavior on a chain with a list index item causes similar behavior?
This code:
Isolate.WhenCalled(() => x.List[3].Name).WillReturn("Name");

Will return a list with 4 items, the first 3 are recursive fakes according to the list item type, and the 4th is a recursive fake with specific behavior defined for the Name property. Does this help?

Doron
Typemock Support


Yes, it sure does, thanks
answered by nsoonhui (59.1k points)
...