コード例 #1
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        // one delegate object  is booldelegate
        // the other is booldelegate2
        public bool PosTest8()
        {
            bool retVal = true;
            //Type,target, method, and invocation list 
            TestLibrary.TestFramework.BeginScenario("PosTest8: hash code of two delegate object is not equal,the two delegate callback different function. ");

            try
            {
                DelegateGetHashCode delctor = new DelegateGetHashCode();
                booldelegate workDelegate = new booldelegate(new TestClass(1).StartWork_Bool);
                booldelegate2 workDelegate1 = new booldelegate2(new TestClass(1).StartWork_Bool);
                if (workDelegate.GetHashCode() == workDelegate1.GetHashCode())
                {
                    TestLibrary.TestFramework.LogError("015", "HashCode is not excepted ");
                    retVal = false;
                }

                workDelegate();
                workDelegate1("hello");

            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("016", "Unexpected exception: " + e);
                retVal = false;
            }

            return retVal;
        }
コード例 #2
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        // one delegate object  is booldelegate
        // the other is booldelegate2
        public bool PosTest8()
        {
            bool retVal = true;
            //Type,target, method, and invocation list 
            TestLibrary.TestFramework.BeginScenario("PosTest8: hash code of two delegate object is not equal,the two delegate callback different function. ");

            try
            {
                DelegateGetHashCode delctor = new DelegateGetHashCode();
                booldelegate workDelegate = new booldelegate(new TestClass(1).StartWork_Bool);
                booldelegate2 workDelegate1 = new booldelegate2(new TestClass(1).StartWork_Bool);
                if (workDelegate.GetHashCode() == workDelegate1.GetHashCode())
                {
                    TestLibrary.TestFramework.LogError("015", "HashCode is not excepted ");
                    retVal = false;
                }

                workDelegate();
                workDelegate1("hello");

            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("016", "Unexpected exception: " + e);
                retVal = false;
            }

            return retVal;
        }