Ejemplo n.º 1
0
 public void Function1(Child obj)
 {
     m_invokeVersion = EnumInvokeVersion.CHILD_CALLED;
 }
Ejemplo n.º 2
0
 public void TestChildren()
 {
     Child[] children = new Child[] { new Child(), new Child() };
     Verify(children,EnumInvokeVersion.CHILD_CALLED);
 }
Ejemplo n.º 3
0
        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
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public void TestIs()
 {
     object obj = new Child();
     Assert.IsTrue(obj is Parent);
     Assert.IsTrue(obj is Child);
 }
Ejemplo n.º 6
0
        public void TestAssignableInNUnit()
        {
            Parent parentObj = new Parent();
            Child childObj = new Child();

            Assert.IsInstanceOf<Parent>(parentObj);
            Assert.IsNotInstanceOf<Child>(parentObj);
            Assert.IsAssignableFrom<Parent>(parentObj);
            Assert.IsAssignableFrom<Child>(parentObj);

            Assert.IsInstanceOf<Child>(childObj);
            Assert.IsInstanceOf<Parent>(childObj);
            Assert.IsAssignableFrom<Child>(childObj);
            Assert.IsNotAssignableFrom<Parent>(childObj);
        }