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'm a beginner and just starting to use TypeMock.
I have a scenario where we need to run regression/integration tests on our application and need to check how it behaves at various times. We cannot change the system time for this purpose and I was hoping to achieve this by mocking DateTime.Now. I added the line to mock DateTime.Now in the main method and while the application builds fine, it throws exceptions when I run it. Can TypeMock be used only in the unit testing context? I even tried to start up the application through the tmockrunner.exe but it still threw errors. Any help on this will be appreciated!

Thanks!
asked by SV1832 (920 points)

15 Answers

0 votes
I have mailed the logs to the email id.
Thanks!
answered by SV1832 (920 points)
0 votes
Hi Shruti,

Thanks for sending the logs.
I've got some questions:

You wrote earlier the you are not interested in unit testing yet you use NUnit.
1) What is the entry point to your program (NUnit test main method in a console)?
Also, can you post this code?
2) On what do you use [TestFixture] and [Test]?
3) What is the command line command that you use to run TMockRunner?
answered by alex (17k points)
0 votes
Hi Alex,

1) The entry point to the program is an exe which loads this plugin dll and others like it. The code I sent was for the plugin that loads the application in which I need DateTime.Now mocked. I'm sorry but I cannot post code for the main entry point to the program since it is company property..
2) You're right, I do not want to use NUnit. In the sample application I wrote though (just to get mocking to work), I was not able to mock DateTime.Now unless I added [TestFixture] to the class and [Test] to the main method, but it turns out those were problems with my settings. That doesn't hold anymore, sorry for the confusion.
3) The command line I use is:
TMockRunner.exe "<exe to run with mocking path>"

Thanks!
answered by SV1832 (920 points)
0 votes
You mention that your program loads a plugin which loads the application. Do you, by any chance load something into a new AppDomain? If yes, make sure that the mocked code is in the same AppDomain as the code setting up CThru.
answered by ulu (1.7k points)
0 votes
Thanks Artëm,
I did check that though and they happen to be on the same appDomain. The application I want mocking to run on has multiple threads, would that affect it?
Thanks!
answered by SV1832 (920 points)
...