How can I use PrivateObject to access private members of both my class and its parent?

前端 未结 7 1998
逝去的感伤
逝去的感伤 2020-12-08 07:41

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

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 08:23

    As André Pena wrote. Why would you like to test private members of the Baseclass through the Subclass. You wouldn't have access to these members in normal code of your Subclass either. You have to make the Properties members protected to have access to them from the Subclass.

    Then you can also test these Members with the PrivateObject.

提交回复
热议问题