I am not sure I still get how to "unit" test legacy code such as this...
Most of my code is to put things and remove things from an object of class A that has a number of other objects inside it and so on like a tree. At the leaf of this tree is a data item object backed by a OR mapped database row... Creating a real object of classA is a non trivial task since it involves creating all the nodes of this tree. I dont even have visibility into the classes beyond one level inside A.
My code needs be exercised when the classAobj is state X and this code will move classAobj to state Y
What would be the best way to get classAobj into state X ?
I have heard Mock objects and Stub objects bandied about but not sure about how I am going to handle anything with deep expectations and how can I create a stub when I need all of the tree ?
How do you discover what other objects are needed for classAobj to function ?