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

As mentioned in title, I'm trying to verify non public static method called with arguements with one of the argument is a Predicate.

I checked that the Predicate return the expected value I want and in fact, I double check that all input arguements are correct as expected 

However, Typemock still throw

TypeMock.VerifyException : 
TypeMock Verification: Method FakeMethod(True /* the result of predicate */ ) was called with mismatching arguments
 
Anyone has any idea if this is a limitation of Typemock ?
asked by cscmh99 (6.1k points)

1 Answer

0 votes

I'm not sure that I fully understand the problem.

Bar is a private static method with a predicate argument.

 
public class Foo
{
    public static void BarWrapper()
    {
        int b = 1;
        Bar(a => a > b);
    }

    private static void Bar(Predicate<int> a)
    {
    }
}

Here I call BarWrapper which calls Bar.
I first fake bar using callOriginal, tos signal Isolator to track this method, then verify it wascalled.

[TestMethod]
public void TestMethod1()
{
    Isolate.NonPublic.WhenCalled(typeof(Foo), "Bar").CallOriginal();

    Foo.BarWrapper();

    Isolate.Verify.NonPublic.WasCalled(typeof(Foo), "Bar");
}

 

Let me know if this is the case post an example of your code.

 

answered by alex (17k points)
Can you try Verify WithExactArgument or Verify WithArgument ?

I mean, make sure the Bar is called with "a > b" as predicate ?
How would you normally compare 2 Predicats?
...