Recently, I was working on the unit test case of legacy code, while writing test cases, I am come up with a problem.
Since I am writing unit test case not integration test. The problem is with private method. In our code a public method is dependent on 5 private method.
For unit test case, I required to give fake implementation of private method, but since method is private, I can't able to-do so. Because MOQ mocking framework did not support the mocking functionality of private method. and even I can't able to write test case of private method.
Possible approach I was thinking
Move all private method in different class. and make them public and also create an interface of this class. In this way I can able to give fake implementation at run-time because now we have Interface of the class.
But the problem in this approach is I need to make this private method to public just for unit test case. so it is a good practice to make it public.