I have a class which has an internal method and I want to mock the internal method. However, it is not calling the mocked function, but the original function. Is there any way to achieve this?
I have many classes and methods of the classes to test using the Moq. Many classes are internal, many have internal methods, many have not-virtual methods. And I cannot change the signature on the methods and classes. How can I go about testing this scenario using Moq? Or what other testing framework could I use which is easy to learn and work with?
Why would you want to mock an internal method?
If you find the need to mock an internal method, say to sidestep a dependency or an interaction, you perhaps should consider redesign of the class.
Inversion of Control and Dependency Injection are some possible design strategies that can reduce coupling and increase cohesion of your classes and eliminate the need to mock internal methods.
I don't believe there is a clear path to non-public mocking with Moq.
But, if you absolutely must, you can use TypeMock Isolator to mock just about anything.
Also, just so it doesn't get lost in the din: Thomas linked a good article on using the free MS Moles to mock non-public members.