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
Below test code will fail with expection "*** Cannot use Isolate.Verify on a static method without first setting static method behavior using Isolate.Fake.StaticMethods()"

Isolate.Fake.StaticMethods(typeof(AuthenticationAttempt<CustomUserLoginAttempt>));  
// Some code calling the static method...    
Isolate.Verify.WasCalledWithArguments(() => AuthenticationAttempt<CustomUserLoginAttempt>.Log(null)).
        Matching(a =>
        {
          CustomUserLoginAttempt loginAttempt = a[0] as CustomUserLoginAttempt;
          return loginAttempt.Attempts == 1;
        });


Obviously typemock supports verification on static method. The only problem i can see is my example is a generic class. So anybody can tell if Typemock can verify in this case. If so, then how? Many thanks.
asked by wk_vigorous (1.2k points)

1 Answer

0 votes
This seems to be a bug in Isolator when faking static methods on generic types. I'll investigate this further and add it to our product backlog. As a workaround, you can probably get away with faking the method directly in a WhenCalled() statement:
Isolate.WhenCalled(() => AuthenticationAttempt<CustomUserLoginAttempt>.Log(null)).IgnoreCall();


Please let me know if the workaround works for you.

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