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
I installed the trial edition of TypeMock and reference the TypeMock.dll file in my project.

I then added the following code

Mock manager = MockManager.Mock(typeof(SomeType));
manager.AlwaysReturn("GetInstance", manager);

When I run the test (the tests are self-executing MbUnit tests) MbUnit throws a FileNotFoundException. I have pasted the IL of the last method in the dump file. Any help you could provide would be appreciated.

***DUMPING***
** Loaded dbghelp.dll
** Saved dump file to 'D:ProjectsColorPoint-Phase-IIThird PartyTypeMockTypeMockWeaver.dmp'
PreCompiled:System.ServiceModel.Diagnostics.ServiceModelPerformanceCounters instance void ReleasePerformanceCounters()
System.ServiceModel.Diagnostics.ServiceModelPerformanceCounters instance void ReleasePerformanceCounters()
Sig: 20 00 01
IL_0 = ldarg.0
IL_1 = ldstr 0x7005E1EC
IL_2 = ldstr 0x7005E26C
IL_3 = ldnull
IL_4 = ldc.i4.0
IL_5 = call 0x0A0024D7
IL_6 = brfalse.s 0x2C
IL_7 = ldarg.0
IL_8 = ldstr 0x7005E1EC
IL_9 = ldstr 0x7005E26C
IL_10 = ldnull
IL_11 = ldc.i4.0
IL_12 = call 0x0A0024DB
IL_13 = dup
IL_14 = ldstr 0x7005E1EC
IL_15 = ldstr 0x7005E26C
IL_16 = call 0x0A0024DA
IL_17 = isinst 0x01000468
IL_18 = brtrue.s 0x02
IL_19 = pop
IL_20 = ret
IL_21 = pop
*INFO: SMALL EH clause TryOffset '0x00000013' HandlerOffset '0x00000042' Flag: 0 Token: 100006c Changed to: TryOffset '0x00000053' HandlerOffset: '0x00000082'
asked by Rixatron (640 points)

4 Answers

0 votes
Hi,

There's not enough info here to help resolve this :? .
I'd like you to produce logs to help isolate the problem. I'll send a separate mail with instructions.
answered by gilz (14.5k points)
0 votes
Hi,

I'm curious about what you are trying to achieve with the code. You return "manager", which is of type Mock.

It makes sense, to return a value of any other type you use, not a TypeMock type. The GetInstance should return something else.

See my separate mail for details.
answered by gilz (14.5k points)
0 votes
It seemed the original exception was as the result of another exception I hadn't noticed because I had turned off exceptions in Visual Studio. doh!

[Edit]
The manager class is basically a singleton class which is called from the method I'm trying to test. So the method would call

Manager.GetManager().SomeFunction

So I was trying to mock out by returning a mock object from the call to GetManager so I could mock out any subsequent calls to that object.

This was the first thing I'd attempted to do so the FileNotFound exception made me think it was a problem with my setup.
[/Edit]
answered by Rixatron (640 points)
0 votes
Hi everyone,

Richard's problem was that he's running tests inside an executable, rather than inside a process of a runner (e.g. NUnit.exe). When you run an app, this way you get the message:
Could not load file or assembly 'TypeMock, Version=0.0.0.0, Culture=neutral, PublicKeyToken?=0000000000000000' or one of its dependencies.


Like all runners, Typemock Isolator needs to be initialized when the process loads. In order to do that, you need to run the process under Typemock's TMockRunner tool. For instance, in the directory when the app is installed, use this:

"c:Program FilesTypemockTypemock IsolatorTMockRunner.exe" TypeMockTest.exe


This treats the exe as a runner and initializes typemock as it loads.
answered by gilz (14.5k points)
...