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
I have a bug in ReturnRecursiveFakes, when the equals method are override.

Here's the production code
    public abstract class SimpleClass
    {
        public string ID
        {
            get;
            set;
        }

        public string Node
        {

            get
            {
                throw new NotImplementedException();
            }
        }
    }

    public  abstract class WrapperClass
    {
        public virtual SimpleClass simClass
        {
            get;
            set;
        }

  
        public override bool Equals(object obj)
        {

            WrapperClass rt = obj as WrapperClass;
            return (rt.simClass.Node == simClass.Node);

        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        
    }

    public class WrapperClassList
    {
        public void Add(WrapperClass wc)
        {
            Debug.Assert(wc.simClass.ID != null, "hello???");
            string testStr = wc.simClass.ID;

        }
    }


Here's the test code
        [Test, Isolated]
        public void TestRecursive()
        {
            WrapperClass sc = Isolate.Fake.Instance<WrapperClass>(Members.ReturnRecursiveFakes);
            Isolate.WhenCalled(() => sc.simClass.ID).WillReturn("1");

            WrapperClassList sclist = new WrapperClassList();
            sclist.Add(sc);


        }


The code will blow up at line
            string testStr = wc.simClass.ID;

________
Henry Ford II history
asked by nsoonhui (59.1k points)

3 Answers

0 votes
This is quite an urgent case, so is it possible to release a patch for me? Thanks.
________
easy vape vaporizer
answered by nsoonhui (59.1k points)
0 votes
I am running in Debug mode.

This is quite an urgent case, so is it possible to release a patch for me? Thanks.

________
BMW E70
answered by nsoonhui (59.1k points)
0 votes
Hi,

We found and fixed the bug. I'm preparing a patch and will send it to your email.

This happened because we mishandled the Equals() overload.

Thanks,
Doron
Typemock support
answered by doron (17.2k points)
...