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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I found that ReturnRecursiveFakes are nto faking private members... thought it should?

Here's the production code:
    public class ListWrapper
    {
        private IList<int> myList;
       

        public void DoNothing()
        {
            myList.Add(1);
        }
    }


And here's the test code:
    [TestFixture, ClearMocks]
    public class TypemockTest
    {
        public TypemockTest()
        {
            
        }

        [Test, Isolated]
        public void TestListWrapper()
        {
            var listWrapper = Isolate.Fake.Instance<ListWrapper>(Members.ReturnRecursiveFakes);
            Isolate.WhenCalled(()=>listWrapper.DoNothing()).CallOriginal();
            listWrapper.DoNothing();

        }
    }

________
The Cigar Boss
asked by nsoonhui (59.1k points)

3 Answers

0 votes
Hi Soon Hui,

The private member you are trying to fake (myList) is a field, and as such not intercepted by Isolator. We had discussions internally about the merit of assigning recursive fakes to these fields, but this is currently not the case.

A quick workaround for this would be accessing a property instead - these are faked automatically with recursive fakes.

Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Hello, it seems to me that I have raised this issue before.

What I want to know is whether the recursive mocking of private members will be supported in the future version? Or t is not supported because of other issues?
________
Amateur Voyeur
answered by nsoonhui (59.1k points)
0 votes
This is not planned for the next version, but it is on our backlog and we may add it to a future version.

Doron
answered by doron (17.2k points)
...