Welcome to Typemock Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!

Is there a way to specify args on WhenCalled

+2 votes
Looking for a work around for the following:

https://www.typemock.com/community/viewt ... =4864#4864
asked Feb 28, 2009 by boo (5,960 points)

6 Answers

+2 votes
Hi Boo,

To follow up on other recent forum postings related to this: this feature (conditional behavior) is in our todo list and will be implemented for an upcoming version. In the meanwhile, you could use one of our older APIs to do this - this page describes how you do it in Natural Mocks: https://www.typemock.com/Docs/UserGuide/ ... tural.html. You can find that and more under our user's guide at https://www.typemock.com/Docs/UserGuide/index.php, under Using Typemock Isolator -> Previous Generation API. Again, we are committed to bring this capability to the AAA API.

Typemock Support
answered Feb 28, 2009 by doron (26,680 points)
+2 votes
What is the time frame on this? I've spent the entire morning trying to get this to work in Natural and it's just been painful so I tried using a combination of reflective and AAA but that's not working either (mock.MockedInstance is returning null).

If it's going to be in the next 2-3 weeks I can live with an inconclusive test or two versus spending much more time trying to work around.

I'm assuming this new feature would be bundled with the feature of WasCalledWithArguments feature that would allow you to have that When logic of reflective mocks in AAA --- which is where I really need it.
answered Mar 4, 2009 by boo (5,960 points)
+2 votes
Hi Brian,

Conditional Behavior feature is one of the next features that will be added to Isolator's AAA API, at this time I cannot give you exact estimate but I hope it will be available the next month.
answered Mar 5, 2009 by dhelper (23,700 points)
+2 votes
Here's the work around I implemented for this lack of feature:
http://www.aaron-powell.com/blog/februa ... eters.aspx
answered Mar 6, 2009 by slace (820 points)
+2 votes
Unfortunately in my case it's not as clear cut of a problem, but good tip and thought though to use extension methods.
answered Mar 6, 2009 by boo (5,960 points)
+2 votes
Yeah, it's only useful if you can practically implement an extension method for what you are mocking (which I was able to do).

Otherwise we've got to wait until Typemock can get it implemented within the API ;)
answered Mar 6, 2009 by slace (820 points)