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
+2 votes
Hi Team,
 
We are upgrading Typemock from version 8.4 to version 8.6(TypemockIsolatorSuite-8.6.0.10.921967232).  I got an exception in one of the test, 
 
Please find the following code snippet simplifies and illustrates the issue
 
Sample C#.Net Code
 
 public class Class1
    {
        private Class2 _c2;
        public Class1(Class2 c2)
        {
            _c2 = c2;
        }
        public void Method1()
        {
            Test t;
            _c2.TestMtd("Testing", out t);
        }       
    }

    public class Class2
    {
        public void TestMtd(string test, out Test t)
        {
            t = new Test();
        }
    }

    public class
Test : IConvertible
    {
        // please implement all the methods from IConvertible, here space is not allowed
    }
 
Typemock UnitTest Code
 
 [TestClass]
    public class UnitTest1
    {
        [TestInitialize]
        public void MyTestInitialize()
        {
            MockManager.Init();
        }

        [TestMethod]
        public void TestMethod1()
        {
            Class2 c2 = Isolate.Fake.Instance<Class2>();
            Class1 obj = new Class1(c2);
            Test t;
            Isolate.WhenCalled(() => c2.TestMtd("test1", out t)).DoInstead(context =>
            {
                t = new Test();
                context.Parameters[1] = t;
            });

            obj.Method1();
        }
    }
 
In the above code, the second parameter I am passing is class inherited from IConvertible. Below exception occurred.
The same code is working fine in TypeMock Version 8.4. Please help us to resolve in Typemock 8.6 Version.
asked by satanova81 (3.7k points)

For IConvertiable Implementation:

public classTest : IConvertible
    {
        public TypeCode GetTypeCode()
        {
            throw new NotImplementedException();
        }

        public bool ToBoolean(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public byte ToByte(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public char ToChar(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public DateTime ToDateTime(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public decimal ToDecimal(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public double ToDouble(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public short ToInt16(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public int ToInt32(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public long ToInt64(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public sbyte ToSByte(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public float ToSingle(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public string ToString(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public object ToType(Type conversionType, IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public ushort ToUInt16(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public uint ToUInt32(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }

        public ulong ToUInt64(IFormatProvider provider)
        {
            throw new NotImplementedException();
        }
    }

Please log in or register to answer this question.

...