I\'m testing a class that is part of a hierarchy. I\'ve been setting up my test classes with the object under test, and a PrivateObject to allow access to that
I wanted to do same thing and I made this extension methods. Now it works well. My initial idea is from your post. Thank you!
https://github.com/cactuaroid/PrivateObjectExtensions
What it's doing basically is finding member owner by Type.GetFields() and Type.GetProperties() recursively, and then create PrivateObject (or PrivateType) as correct type to access the member.