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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi

I am currently evaluating whether to get TypeMock for our product or not.
One functionality that is important is the ability to stub and verifycalls on generic methods.

e.g.
private void MyFunction<T>() where T:SomeBaseClass{...}

When testing I found that this is possible:

[TestMethod]
...
myObj.ExpectAndReturn("MyFunction", "monkey");
...
myObj.Verify();



This will ignore the generic parameter on MyFunction and treat all instances the same way. However, I prefer to use the Arrange Act Assert syntax, rather than setting up expectations and verifying them.

I tried something like this, but it doesn't seem to work. Anyone know what I am doing wrong, or is it not possible?


[TestMethod]
...
Isolate.NonPublic.WhenCalled(myObject, "MyFunction").WillReturn("monkey");
...
Isolate.Verify.NonPublic.WasCalled(myObject, "MyFunction");


Thank you
/Kjell
asked by Kjell (600 points)

1 Answer

0 votes
Hi,

The AAA API does not have an explicit way to fake or verify generic private members. There's a workaround to use the natural mocks API as you've discovered.

We'll add this feature to our backlog. Meanwhile, let us know if you succeed in coding the test.

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
...