private void Verify(Parent[] parms,EnumInvokeVersion invokeVersion)
 {
     Utility util = new Utility();
     foreach (Parent parm in parms)
     {
         parm.Method1(util);
         Assert.AreEqual(invokeVersion,util.InvokeVersion);
         util.InvokeVersion = EnumInvokeVersion.UNDEFINED;
     }
 }
 public void Setup()
 {
     m_deriveObj = new DeriveClass();
     m_baseRef = m_deriveObj;
     m_parm = new Utility();
 }
 public override void Method1(Utility parm)
 {
     parm.InvokeVersion = EnumInvokeVersion.CHILD_CALLED;
 }
 public virtual void Method1(Utility parm)
 {
     parm.InvokeVersion = EnumInvokeVersion.PARENT_CALLED;
 }
        public void TestVirtualOverride()
        {
            #region [parent version called]
            Utility parm1 = new Utility();
            Assert.AreEqual(EnumInvokeVersion.UNDEFINED, parm1.InvokeVersion);

            Parent parentObj = new Parent();
            parentObj.Method1(parm1);
            Assert.AreEqual(EnumInvokeVersion.PARENT_CALLED, parm1.InvokeVersion);
            #endregion

            #region [child version called]
            Utility parm2 = new Utility();

            Child childObj = new Child();
            childObj.Method1(parm2);
            Assert.AreEqual(EnumInvokeVersion.CHILD_CALLED, parm2.InvokeVersion);
            #endregion
        }
        public void TestOverload()
        {
            Child child1 = new Child();
            Assert.IsInstanceOf<Parent>(child1);

            Utility helper4Child = new Utility();
            // it will call the method with exact parameter type, will not cast to its base class version
            helper4Child.Function1(child1);
            Assert.AreEqual(EnumInvokeVersion.CHILD_CALLED, helper4Child.InvokeVersion);

            Utility helper4Parent = new Utility();
            // if you want to call the base version, you need explicit cast
            helper4Parent.Function1((Parent)child1);
            Assert.AreEqual(EnumInvokeVersion.PARENT_CALLED, helper4Parent.InvokeVersion);
        }
 public override void OverrideFunc(Utility parm)
 {
     parm.InvokeVersion = EnumInvokeVersion.CHILD_CALLED;
 }
 public new void NewFunc(Utility parm)
 {
     parm.InvokeVersion = EnumInvokeVersion.CHILD_CALLED;
 }
 public virtual void OverrideFunc(Utility parm)
 {
     parm.InvokeVersion = EnumInvokeVersion.PARENT_CALLED;
 }