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

前端 未结 7 1994
逝去的感伤
逝去的感伤 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:33

    PrivateObject is a bit on the "dumb" side when it comes to handling inheritance. Unfortunately, its methods are not virtual, so there's no easy way to change this behaviour. You essentially have two options: either live with the limitations or create your own private accessor helper that can handle inherited members transparently.

提交回复
热议问题