How can I verify the number of times a friend parameter method is called?

0 votes

To verify the number of times a friend parameter method is called I have used below code 

Isolate.NonPublic.WhenCalled(fakeDeposit, "ValidateISAContributionLimit").DoInstead(Function(c)
                                                                                                methodCallCount += 1
                                                                                                c.WillCallOriginal()
                                                                                            End Function)

 

But the above code is throwing below run time exception

*** WhenCalled() with a fake object can only be used on instance methods. To set behavior on static method WealthNET.Server.Deposit.ValidateISAContributionLimit use WhenCalled() with a type argument

Thanks in advance

 

 

asked Apr 6 by onkarw210 (140 points)

1 Answer

0 votes

Hi onkarw210,

Does the "ValidateISAContributionLimit" Method is a static method?

If its a static method, the WhenCalled method takes the dependency type as the first parameter,

for example: 


Isolate.NonPublic.WhenCalled(GetType(fakeDeposit), "ValidateISAContributionLimit").DoInstead(Function(c)
                                                                                        methodCallCount += 1
                                                                                        c.WillCallOriginal()
                                                                                    End Function)
 
Cheers,
Daniel
Typemock Support. 
 
answered Apr 23 by Daniel (1,340 points)
...