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 Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!
0 votes
Hi,

Can you please assist me with faking the iteration in the foreach loop in the following code?

  public class Class1
  { 
        MySystem system;

        private void GenerateObjectXML(IObject obj)
        { 
            NodeRef nodeRef = new StructureNodeRef(obj); 
            IStructureN structureNode = system.currentManager.Operations.GetNode(nodeRef); 
            IStructureNCollection structureNodeCollection = structureNode.ListDescendents();
 
            if (structureNodeCollection != null) 
            { 
                foreach (IStructureNode node in structureNodeCollection)  
                {
                    String name = node.GetName;
                } 
            }

        }
  }
asked by (9.1k points)

2 Answers

0 votes
I think that this is what you are looking for:
Isolate.WhenCalled(()=>system.currentManager.Operations.GetNode(null).ListDescendents()).WillReturnCollectionOf(new [] { Isolate.Fake.Instance<IStructureNode>()});
answered by (18k points)
0 votes
Thanks, that did the trick :D
answered by (9.1k points)
...