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 have a strange problem with DateTime.Now. When I Run simple test:
        [Test, Isolated]
        public void DateTimeNow_Test()
        {
            DateTime fakedDate = new DateTime(2009, 12, 1);
            Isolate.WhenCalled(()=>DateTime.Now).WillReturn(fakedDate);
            Assert.AreEqual(new DateTime(2009,12,1),DateTime.Now);
        }


I get exception: TypeMock.TypeMockException:
*** No method calls found in recording block. Please check:
* Are you trying to fake a field instead of a property?
* Are you are trying to fake mscorlib type?


I've locally installed TM 5.4.5 and I add TypeMock and TypeMock.ArrangeActAssert dll's into my project. Previously I had installed older TM version - I started with 5.3.1 but never have to mock DateTime.Now. I read on forum that someone has the same problem after upgrading TM to 5.3.5 version but I don't see any solution.

Do you have any experience with this problem? How to check which TM version is really use during tests execution? Any idea would be nice.

br
tlucz
asked by tlucz (2.9k points)

7 Answers

0 votes
Hi,

Can you make sure you have Typemock.Interceptors.dll installed in GAC? that's under c:windowsssembly. What version is this assembly at?

Doron
Typemock Support
answered by doron (17.2k points)
0 votes
I've already check it. In local GAC I have TypeMock 5.4.5 and TypeMock.Interceptors 5.4.5 installed. Should I have Interceptors also in project folder?

I run tests by Resharper and in log file I get message:

"Unable to CoInitialize Meta-data Dispenser failed => Cannot change thread mode after it is set.

Unable to open assembly scope for Typemock.Interceptors.dll => Cannot change thread mode after it is set."

maybe it is a clue.
answered by tlucz (2.9k points)
0 votes
I'm unfamiliar with the Resharper exception message - can you try running the test through another test runner and let me know if it behaves differently?

Doron
Typemock Support
answered by doron (17.2k points)
0 votes
When I run test locally from Nunit gui I also get this exception. I know that it is not really TM issue cause on my build server environment all work correctly.

So it is rather problem on my local PC. I hope that you got previously information about this strange behaviour from other users and know any advices. If not I try find what really happens on my PC.

thanks for quick answer
br
tlucz
answered by tlucz (2.9k points)
0 votes
tlucz,

This sort of error would happen if Typemock assemblies in the GAC are old or duplicated. Can you try uninstalling, then making sure your GAC doesn't have Typemock.dll or Typemock.Interceptors.dll before re-installing?

Please let me know if this helps.

Doron
Typemock Support
answered by doron (17.2k points)
0 votes
hi,
unfortunatelly it doesn''t help :(
answered by tlucz (2.9k points)
0 votes
OK, I'll need more info, so let's take this offline. I'll email you from our support mailbox for more details.

Doron
Typemock Support
answered by doron (17.2k points)
...