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 Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!
0 votes
What is the difference between [Isolate] and Isolate.CleanUp() ?

Also, what is actually done within each of the two function?

Thanks,

Jason
asked by (2.3k points)

4 Answers

0 votes
Follow up question: functionally speaking, is there a difference between calling Isolate.CleanUp() before and calling it after the test method?
answered by (2.3k points)
0 votes
Hi Jason,

Functionaly speaking there (as far as i know) no difference between the two.
the true difference is in their usage (I also think that the usage of [Isolate] technically get translated to Isolate.Cleanup() ).

In both cases, the inner structures of the Isolate framework get cleaned. i.e. all set behavior and fakes are disposed of.

:!: Be advised that if the actual call to Isolate.Cleanup() is inside the test method, it might get bypassed in case the test fails.

About your second question, under most scenario there should not be any difference. However, there is some code executed (related to the testing Framework)between the end of a test and the start of the next test, and I did encounter some edge cases when some faking did effected that.

:?: Is there a special reason not to use the [Isolate] / call cleanup at the end of TearDown?

:idea: [Isolate] can also be used on the test class level. Which might be best if like me you belong to the the forgetful tribe.
answered by (6.6k points)
0 votes
Just to be sure, if I have the following code, will the call to GetCarByVin on the third line call the actual implementation? In other words, does CleanUp() undo all mock set ups?

Isolate.WhenCalled(() => CarService.GetCarByVin<User>(null)).WillReturn(null);
Isolate.CleanUp();

Car car = CarService.GetCarByVin("123");


Hi Jason,

Functionaly speaking there (as far as i know) no difference between the two.
the true difference is in their usage (I also think that the usage of [Isolate] technically get translated to Isolate.Cleanup() ).

In both cases, the inner structures of the Isolate framework get cleaned. i.e. all set behavior and fakes are disposed of.

:!: Be advised that if the actual call to Isolate.Cleanup() is inside the test method, it might get bypassed in case the test fails.

About your second question, under most scenario there should not be any difference. However, there is some code executed (related to the testing Framework)between the end of a test and the start of the next test, and I did encounter some edge cases when some faking did effected that.

:?: Is there a special reason not to use the [Isolate] / call cleanup at the end of TearDown?

:idea: [Isolate] can also be used on the test class level. Which might be best if like me you belong to the the forgetful tribe.
answered by (2.3k points)
0 votes
Hi,

Yes you should get to the real implementation.
answered by (6.6k points)
...