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
0 votes
After calling Isolate.Fake.StaticMethods(Type) on my static class, I was banging my head as to why calls to that class that were not specified with Isolate.WhenCalled() were not throwing a TypeMockException. The documentation says that "Using this overload is equal to using Members.MustSpecifyReturnValues".

A few long debugging sessions later, I tried to explicitly specify that I want Members.MustSpecifyReturnValues by calling the overload Isolate.Fake.StaticMethods(Type, Members). Only then was I getting exceptions thrown.

A quick check with reflector confirmed it: in complete contrast with the documentation, Isolate.Fake.StaticMethods(Type) actually uses Members.ReturnRecursiveFakes!

The problem is, fixing the documentation will not alert the people who were relying on the Members.MustSpecifyReturnValues behavior, and are actually running bad tests (like me), and changing the behavior of the existing method to Members.MustSpecifyReturnValues breaks backwards compatibility and might cause existing passing tests to fail.

Though I think breaking existing tests to assert the correct behavior would be the lesser evil. Do you agree?

EDIT: Using Isolator 6.0.6.0
asked by allon.guralnek (10.6k points)

1 Answer

0 votes
Hi Allon,

This is indeed a mistake in the documentation! Thanks for letting us know about it.

As for your question - I think that in this case fixing the documentation will be good enough in this case since the the default behavior changes to recursive fakes quit early in the API life so I believe that aren't many user relying on this.
answered by ohad (35.4k points)
...