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)

4 Answers

0 votes
Hello,

The code you posted should not have failed.
Are you using the latest version of Isolator?
Could you please post the code for AuthenticationAttempt<T>, or better yet, send us a small reproduction to support at typemock.com?

Thanks!
answered by igal (5.7k points)
0 votes
public class AuthenticationAttempt<T> where T : LoginAttemptInfo
  {    
    public static void Log(T loginInfo) 
    {
        loginInfo.CreateUserLoginAttempt();
    }
  }

public abstract class LoginAttemptInfo
{    
    public abstract void CreateUserLoginAttempt();
}


Here are the definitions of the 2 classes. CustomUserLoginAttempt is derived from LoginAttemptInfo. Can you tell me why my test failed? My typemock version is 6.0.4.0.
answered by wk_vigorous (1.2k points)
0 votes
We'll try to get a local repro going, but this seems like a bug in Isolator. In the meanwhile, can you try explicitly faking the method you are verifying using WhenCalled()? This should work around the issue.

Please let me know if this helps.

Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Hi i tried whencalled() but it didn't help.
thansk.
answered by wk_vigorous (1.2k points)
...