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
When i use typemock to isolate a static method, there is something wrong with ConfigurationManager AppSetting.
Here is my class:
public class TestTypeMock
    {
        public static readonly string IsTypeMockTest = ConfigurationManager.AppSettings["IsTypeMockTest"];

        public static void WriteTestMessage()
        {
            Console.WriteLine(ConfigurationManager.AppSettings["IsTypeMockTest"]);
        }
    }

Here is my test code:
[TestMethod]
        [Isolated]
        public void WriteTestMessageTest()
        {
            Isolate.WhenCalled(() => TestTypeMock.WriteTestMessage()).IgnoreCall();
            //Assert.IsNotNull(TestTypeMock.IsTypeMockTest);
            Assert.IsNotNull(ConfigurationManager.AppSettings["IsTypeMockTest"]);
        }

This case failed because the value is null, but when i uncomment the commented line, the case passed. Why I got this result? This error makes many of our test cases failed.
asked by nofireice (680 points)

4 Answers

0 votes
Hi,

Which Isolator version do you use?

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
0 votes
The version is 6.1.2.0
answered by nofireice (680 points)
0 votes
Hi,

Which Isolator version do you use?

Regards,
Elisha,
Typemock Support


Could you please give me any solution?
answered by nofireice (680 points)
0 votes
Hi,

It seems like an bug in an previous version which was already fixed. I checked it on a new version and it does not reproduce anymore. Can you please try the new version and let me know if it solved the problem? You can download the fix here.
answered by Elisha (12k points)
...