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
Hi,

I'm new to TypeMock, and I'm trying to figure out if it supports a specific use case that I have. I have a concrete type with a method. And I was to have the return of that method be controlled by my test (to return a mock), but only if a certain input type is passed in. If any other input type is passed in, the actual method on the concrete type should be called.

I seem to be able to get TypeMock to either always intercept the call and return the mock, or always allow the concrete call, but not dynamically based on input value.

Any enlightenment you could provide would be greatly appreciated.

Thanks,

~ Justin
asked by jkohlhepp (600 points)

1 Answer

0 votes
Hi Justin,

What you are looking for is called conditional expectations (using the WhenArgumentsMatch method). You can look it up on the help file and on the how-to page:
https://www.typemock.com/Docs/HowTo.html - look for "Faking calls based on arguments".

What you basically do is set an expectation, and use the WhenArgumentsMatch method, inside the recording block. Later in the test code, when you call the method you want to mock, TypeMock will compare the sent argument with the expected argument from the expectation setting, and will mock the method if they match.

Let me know if you have more questions.
answered by gilz (14.5k points)
...