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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Try this code
    public class AssignMyself
    {

        public double px
        {
            get;
            set;
        }

        public double py
        {
            get;
            set;
        }

        public override bool Equals(object obj)
        {
            if (!(obj is AssignMyself))
                throw new Exception();
            return base.Equals(obj);
        }
    }

    public class DoNothing
    {
        public AssignMyself myselfObj
        {
            get;set;
        }

    }


    [TestFixture, ClearMocks]
    public class PubMethod
    {
        [Test, Isolated]
        public void UnitMe()
        {
            var nothing = Isolate.Fake.Instance<DoNothing>();
            nothing.myselfObj = CreateDoNothing();
            Assert.IsNotNull(nothing.myselfObj);
          
        }

        private AssignMyself CreateDoNothing()
        {
            return new AssignMyself() { px=10, py=20};
        }
    }

I will get an exception thrown at
   at w.a(Object A_0, Type A_1)
   at w.a(Object A_0, Object[] A_1, Type A_2, Scope A_3, Int32 A_4, Object A_5, Type A_6)
   at ca.a(String A_0, Object[] A_1, Object A_2, Object A_3, String A_4, Type A_5)
   at Esteem.Archi.DoNothing.get_myselfObj()
   D:Esteem software projectEsteem7ug listInternalVisibleEsteem.ArchiPubMethod.cs(52,0): at Esteem.Archi.PubMethod.UnitMe()
   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)


It seems that after the true property is set, it will return an exception because the Equals method is called: and the value that passes into Equals is not correct.

Is this a bug?
________
CALIFORNIA DISPENSARIES
asked by nsoonhui (59.1k points)

1 Answer

0 votes
Soon Hui,

This indeed seems like a bug :(. I'll need to find out why this happens and get back to you - the issue does seem related to the overloaded equality method.

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