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 all,
I found a possible bug in TypeMock when mocking base generic class. Look at the following code:

        internal class BaseGeneric<T>
        {
            internal List<T> _collection = null;

            internal BaseGeneric()
            {
                _collection = new List<T>();
            }

            internal bool Apply()
            {
                foreach (T elem in _collection)
                {

                }

                return false;
            }
        }

        internal class Derived : BaseGeneric<int>
        {
            
        }

        [TestFixture]
        [ClearMocks]
        public class TestDerived
        {
            [Test]
            [VerifyMocks]
            public void TestBoo()
            {
                Mock<Derived> mock = MockManager.Mock<Derived>();
                mock.AlwaysReturn("Apply", true);

                Derived rules = new Derived();
                Assert.IsTrue(rules.Apply());
            }
        }


When running this test (pattern extracted from our code), I always receive the following stack:

System.NullReferenceException: Object reference not set to an instance of an object.
at BaseGeneric`1.Apply() in BaseGeneric.cs: line 19
at TestDerived.TestBoo() in BaseGeneric.cs: line 46
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)
at TestDerived.TestBoo() in BaseGeneric.cs: line 41 


Enviroment:
* TypeMock Isolator 5.3.0
* Visual Studio 2005

Please note that with TypeMock 5.0.0 all is working fine.
Please let me know if there is any workaround or planned fix for this problem.

Thanks
asked by Deimos (4.7k points)

4 Answers

0 votes
Hi Deimos,

This could be an issue we've fixed in the upcoming version of Typemock Isolator, I'd like to test this theory with you - Lets take it offline
answered by dhelper (11.9k points)
0 votes
Hi,

We are currently using Typemock 4.1.0.0 and are considering upgrading to the latest version (5.3.0.0). We ran our existing unit tests with the latest version and I believe this bug is the cause of a number of new failures. Would it be possible for you to send me the new version so that we could verify that this is indeed the cause and that there aren't any other problems lurking?

Thanks,
Tibor
answered by tibor (1.8k points)
0 votes
Hi Tibor,

I'm sending you our latest build which includes a fix to this problem. Please let us know if this resolved your upgrade issues, or report them here and we'll work through them.

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Hi,
Is there any estimation on when this fix goes to release? We're excited to move to 5.3! =]

Thanks,
3ter
answered by 3ter (2.5k points)
...