When can we mock an object and its methods?

Posted by Shailendra on Stack Overflow See other posts from Stack Overflow or by Shailendra
Published on 2010-05-10T06:58:38Z Indexed on 2010/05/10 7:04 UTC
Read the original article Hit count: 183

Filed under:

I am novice to the Moq and unit testing. I have to write unit tests to a lot of classes which has the objects of other classes. can i mock the methods of the class objects. Here is the exact scenerio-

I have a class two classes A and B and A has a private object of B and in a method of A i am internally calling the method of B and then doing some calculation and returning the result. Can i mock the method of B in this scenerio? Please try to give me full detail about the conditions where i can mock the methods and functions of the class. Thanx

© Stack Overflow or respective owner

Related posts about moq