Protected Virtual Methods 保护域中的虚拟方法
Protected Access Methods 保护域中的访问方法
Protected Class methods 受保护的类方法
Sometimes you need to write a subclass (often as an inner class) in order to test protected methods.
有时需要编写一个子类(通常作为内部类)来测试 protected 的方法。
By definition, you cannot inherit from a sealed type, which means that protected methods on sealed types cannot be called.
按照定义,不能从密封类型继承,意味着不能调用密封类型上受保护的方法。
This approach makes testing protected methods much easier because the test case class can now extend the class that contains the protected methods.
这种方法使得测试受保护的方法非常容易,因为测试案例类现在可以扩展包含受保护方法的类了。
应用推荐