Monday, September 30, 2013

Clever or Ghetto: A way to "test" private methods in C#?

You could make all of your private methods protected and then in your test project make an object which inherits from your object that has the protected methods. You then have both encapsulation and testing. Is this legitimate? As I think about it, I suppose the child object for testing would have to have public convenience methods that one could call which would just fall over to the projected methods. Hmmm. Now my idea is getting a little too complicated. Good morning.

No comments:

Post a Comment