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
Test that passes:

         //Arrange
         Isolate.Fake.StaticMethods(typeof(Utility));
         Isolate.WhenCalled(() => Utility.GetCachedValue<NVList>(null)).ReturnRecursiveFake();

         //Act
         NVList list = NVList.GetNameValueList();

         //Assert
         Isolate.Verify.WasCalledWithAnyArguments(() => Utility.GetCachedValue<NVList>(null));


Test that fails (original method is called even though it should be faked and Verify fails):

         //Arrange
         Isolate.Fake.StaticMethods(typeof(Utility));

         //Act
         NVList list = NVList.GetNameValueList();

         //Assert
         Isolate.Verify.WasCalledWithAnyArguments(() => Utility.GetCachedValue<NVList>(null));


I have to believe the reason the second is not working as expected is because the return of what is suppose to be the faked static method is a generic rather than a specific type. I have another test that is exactly the same as this second test which isn't working correctly but it runs as expected; the only difference is that it is a 'void' method in the utility rather than one that returns a specific type that is generic.
asked by boo (21.8k points)

4 Answers

0 votes
I need the code under test to further investigate this issue - let's take it offline
answered by dhelper (11.9k points)
0 votes
Dror,

:?: Might it be that the default beavior of static method after the usage of
Isolate.Fake.StaticMethods(...)
is set to Members.MustSpecify? (unlike the default when creating a faked instance)
answered by error (6.6k points)
0 votes
The default behavior is return recursive fakes
answered by dhelper (11.9k points)
0 votes
Hi Boo,

I just wanted to let you know I successfully recreated this behavior and I'm working on a patch for this. I'll contact you offline once it's ready, and also incorporate it with our next version.

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
...