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

Isolate.Fake.StaticConstructor - works only once

0 votes
Hi -

I need to fake a static contractor type.
I added the following to my test class :
 [ClassInitialize]
        public static void InitClass(TestContext tc)
        {
            //// fake icfc element creation
            Isolate.Fake.StaticConstructor(typeof(Factory));
            Isolate.Fake.StaticMethods(typeof(Factory), Members.ReturnRecursiveFakes);            
        } 


i have 2 test methods which uses this fake but is seems that it apply only for thr first one, the second one actually invokes the static ctor for some reason and fails.

i'm using typemock version 6.0.10.

can anyone can explain why is it behave like that ?
Itay.
asked Apr 21, 2013 by itayer (3,100 points)

1 Answer

0 votes
You can workaround this issue using our old API:

        [TestInitialize]
        public void InitTest()
        {
            MockManager.MockAll(typeof (Factory));
        }


MockManager.MockAll should be used before every test or in it's beginning so it's best to put it in the [TestInitialize].

You can find more info on MockAll here.
answered Apr 25, 2013 by alex (17,950 points)
...