chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Sometimes I want to mock a method on an object (typically a singleton) that may already exist. Since the creation of my particular object is complex, I use MockAll to mock that method.

I think I have read somewhere on the forum or in the documentation that it is not easy to stop the MockAll method and that MockManager.ClearAll does not do the trick, but I have been unable to find the documentation. So, my question is:

Once I start mocking an object with MockAll, is the MockAll functionality stopped at the end of the test when I call MockManager.ClearAll () or does this just clear the expectations. How can I ask the MockManager to stop Mock'ingAll instances of an object.

Thanks in advance.
asked by sellingerd (5.7k points)

1 Answer

0 votes
These methods will clear and remove a MockAll
:arrow: MockManager.Verify()
:arrow: MockManager.ClearAll()
:arrow: MockManager.Init()

If you don't use the above methods the following is correct:
Once you have a MockAll you cannot create another MockAll for the same type.

using mock.Clear() will clear all the expectation but you still wont be able tp create another MockAll.

:idea: Here is how to reuse a MockAll:
Use MockManager.GetMockAll to retrive the MockAll and then Clear it and define new expectations
answered by scott (32k points)