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
Hi,

I'm getting this error when multiple tests in a testfixture run.

"TypeMock.TypeMockException :
*** Static constructor for class Roller cannot be faked as it has already
been called
at g4.a(Type A_0)
at g4.b(Type A_0)
at g4.StaticConstructor()"


If I run them one by one it works just fine.


Code

private static Roller GetMockedRoller()
 {
 Isolate.Fake.StaticConstructor<Roller>();
 var mockedRoller =
 Isolate.Fake.Instance<Roller>(Members.ReturnRecursiveFakes);
 return mockedRoller;
 }


Which I understand why it might be happening, so I moved
Isolate.Fake.StaticConstructor<Roller>(); to [TestFixtureSetUp] but when I
do this, it doesn't work expected for the second test, this time Static
constructors are failing in the second test.

How can I solve this problem? Is it a bug, or am I missing something?


Thanks,
James
asked by JamesKing (8.2k points)

1 Answer

0 votes
Hi,

The issue is an old bug which we fixed in the later versions.
You are welcome to download our latest version from www.typemock.com/download.
answered by Shai Barak (1.5k points)
Is this fix available with version 8 and the later versions? I am using a version 8.1.11 and having the same issue occuring
...