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've got a series of tests for a class that uses a Static Class. This static class has a static ctor.

When I try running the 6 tests which uses the Isolator "Isolate.Fake.StaticConstructor(typeof(X));" syntax and has the [Isolated] against it, 1 will pass and the other 5 will fail stating:

Static constructor for class X cannot be faked as it has already been called.

I thought the Isolated attribute cleaned up the tests so I could do this?

I'm using the 64bit version 5.4.3.

Cheers,
John
asked by Imaji (2.2k points)

4 Answers

0 votes
Hi,

Can you please try running the tests with the latest version of the Isolator (6.0.0)?
We fixed many issues since 5.4.3 so you might be fighting against a problem that is already fixed.

You can download it from here
Note that version 6.0 has single installer for 32 and 64 bit OS.
answered by ohad (35.5k points)
0 votes
Hi,

We've tried upgrading to 6.0, but this caused us no end of pain with test execution rising dramatically and breaking a lot more.

We've spoken to a support person via phone and are awaiting a reply.

Cheers,
John
answered by Imaji (2.2k points)
0 votes
Hi,
I have a static class with a static constructor called AppSettings.
When i wrote a second test with the rows:
Isolate.Fake.StaticConstructor<AppSettings>();
AppSettings.CurrentCache = HttpContext.Current.Cache;
The tests passes individually but when i run all tests, the second one fails with:
"Static constructor for class AppSettings cannot be faked as it has already been called"
I have Isolated attribute in each function and i tried to move both rows to TestInitialize but with no luck...

Please advise
Alon
answered by alonav (220 points)
0 votes
Hi Alon,

Please contact our support: support at typemock.com.
We would appreciate if you could provide a code sample to help us reproduce the issue.

Regards,
Anna,
Typemock Support
The Unit Testing Company
answered by anna (260 points)
...