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
Here's the code that worked fine for months. It was broken by newest Isolator version (5.4.5):

    public class BaseClass
    {
        protected bool m_Enabled;

        public virtual bool Enabled1 { get { return m_Enabled; } set { m_Enabled = value; } }
        public virtual bool Enabled2 { get; set; }
        public virtual bool GetEnabled() { return false; }
    }

    public class SubClass : BaseClass
    {
    }

    [TestFixture]
    [Isolated]
    public class TestClass2
    {
        [Test]
        public void Enabled1_BaseClass()
        {
            var fake = Isolate.Fake.Instance<BaseClass>();
            Isolate.Swap.NextInstance<BaseClass>().With(fake);

            BaseClass bc = new BaseClass();
            bc.Enabled1 = false;
            Assert.IsFalse(bc.Enabled1);
        }

        [Test]
        public void Enabled1_SubClass()
        {
            var fake = Isolate.Fake.Instance<SubClass>();
            Isolate.Swap.NextInstance<SubClass>().With(fake);

            SubClass sc = new SubClass();
            sc.Enabled1 = false;
            Assert.IsFalse(sc.Enabled1);
        }

        [Test]
        public void Enabled2_BaseClass()
        {
            var fake = Isolate.Fake.Instance<BaseClass>();
            Isolate.Swap.NextInstance<BaseClass>().With(fake);

            BaseClass bc = new BaseClass();
            bc.Enabled2 = false;
            Assert.IsFalse(bc.Enabled2);
        }

        [Test]
        public void Enabled2_SubClass()
        {
            var fake = Isolate.Fake.Instance<SubClass>();
            Isolate.Swap.NextInstance<SubClass>().With(fake);

            SubClass sc = new SubClass();
            sc.Enabled2 = false;
            Assert.IsFalse(sc.Enabled2);
        }

        [Test]
        public void GetEnabled_BaseClass()
        {
            var fake = Isolate.Fake.Instance<BaseClass>();
            Isolate.Swap.NextInstance<BaseClass>().With(fake);

            BaseClass bc = new BaseClass();
            Assert.IsFalse(bc.GetEnabled());
        }

        [Test]
        public void GetEnabled_SubClass()
        {
            var fake = Isolate.Fake.Instance<SubClass>();
            Isolate.Swap.NextInstance<SubClass>().With(fake);

            SubClass sc = new SubClass();
            Assert.IsFalse(sc.GetEnabled());
        }
    }



All tests should pass. However, two of them fail with "null reference" exception:

TestCase 'TypeMockTest.TestClass2.Enabled1_SubClass'
failed: System.NullReferenceException : Object reference not set to an instance of an object.
at e1.a(MethodBase A_0, Object[] A_1)
at f8.a(MethodBase A_0, Object[] A_1, TypeParams A_2)
at ce.a(String A_0, Object[] A_1, Object A_2, Object A_3, String A_4, Type A_5)
at c8.a(String A_0, Object A_1, MethodBase A_2, Object[] A_3, Object A_4, String A_5, ce A_6)
at c8.b(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
C:ProjectsNETTypeMockTestMyClass2.cs(15,0): at TypeMockTest.BaseClass.set_Enabled1(Boolean value)
C:ProjectsNETTypeMockTestMyClass2.cs(46,0): at TypeMockTest.TestClass2.Enabled1_SubClass()
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
C:ProjectsNETTypeMockTestMyClass2.cs(41,0): at TypeMockTest.TestClass2.Enabled1_SubClass()

TestCase 'TypeMockTest.TestClass2.Enabled2_SubClass'
failed: System.NullReferenceException : Object reference not set to an instance of an object.
at e1.a(MethodBase A_0, Object[] A_1)
at f8.a(MethodBase A_0, Object[] A_1, TypeParams A_2)
at ce.a(String A_0, Object[] A_1, Object A_2, Object A_3, String A_4, Type A_5)
at c8.a(String A_0, Object A_1, MethodBase A_2, Object[] A_3, Object A_4, String A_5, ce A_6)
at c8.b(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
at TypeMockTest.BaseClass.set_Enabled2(Boolean value)
C:ProjectsNETTypeMockTestMyClass2.cs(68,0): at TypeMockTest.TestClass2.Enabled2_SubClass()
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
C:ProjectsNETTypeMockTestMyClass2.cs(63,0): at TypeMockTest.TestClass2.Enabled2_SubClass()


4 passed, 2 failed, 0 skipped, took 1,42 seconds (NUnit 2.5).
asked by vagif (19.4k points)

9 Answers

0 votes
Hi Vagif,

I've run the tests and they passed, I'd like to send you a patch of our newest version so you can check if the problem was solved on a newer version.

Dror
answered by dhelper (11.9k points)
0 votes
Hi Vagif,

I've run the tests and they passed, I'd like to send you a patch of our newest version so you can check if the problem was solved on a newer version.

Dror


Go ahead, Dror! Thanks.

Vagif
answered by vagif (19.4k points)
0 votes
Hi Vagif,

I've run the tests and they passed, I'd like to send you a patch of our newest version so you can check if the problem was solved on a newer version.

Dror


Tests passed with the patch.
Thanks!
answered by vagif (19.4k points)
0 votes
Hi Vagif,

I've run the tests and they passed, I'd like to send you a patch of our newest version so you can check if the problem was solved on a newer version.

Dror


I need the patch as well. How can I obtain it?
answered by dblack (8.4k points)
0 votes
Sent :D
answered by ohad (35.4k points)
0 votes
Sent :D


Hi Dave,

I sent you the patch please let me know if it helps.



Hi Ohad,

I only received one email from you with a link. Does this 5.4.6 patch include fixes for *both* of the following?

1. Isolate.NonPublic is broken in 5.4.5 - https://www.typemock.com/community/viewt ... highlight=

AND

2. Inherited virtual properties are broken in Isolator 5.4.5 -
https://www.typemock.com/community/viewt ... highlight=
answered by dblack (8.4k points)
0 votes
Hi,

The installer I sent you is the latest build that includes fixes for both of the problems.
answered by ohad (35.4k points)
0 votes
Hi Vagif,

I've run the tests and they passed, I'd like to send you a patch of our newest version so you can check if the problem was solved on a newer version.

Dror


Hi
We are also having problems with setting properties on SPWeb's Properties, although in previous versions there were none. Can you send me link to patch also?

Best regards
Damian
answered by damiand2 (2k points)
0 votes
Hi Damian,

The new Isolator version (6.0) that includes the fix will be available for download in few hours from our download page
answered by ohad (35.4k points)
...