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 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!
0 votes
Stubbing DateTime.Now from inside a DoInstead() throws an exception:

[ img ]
Code for the above:
asked by (27.7k points)

2 Answers

0 votes
Hi Neil,

This issue is caused due to the behavior set inside the DoInstead block. Setting faked behavior inside DoInstead is no supported and it causes this exception.

Typemock Support
answered by (12k points)
0 votes
Thanks Elisha. Could a message be added to the exception to say not supported?

To work around this I will refactor my now-dependent method and the method that calls my now-dependent method so I can stub DateTime.Now outside of a DoInstead.
answered by (27.7k points)