Exemple #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 booldelegate1
        public bool PosTest2()
        {
            bool retVal = true;

            //Type,target, method, and invocation list
            TestLibrary.TestFramework.BeginScenario("PosTest2: hash code of two different delegate object even though  they invoke the same function  is not equal ");

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

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

            return(retVal);
        }
Exemple #2
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        // the same delegate object  is booldelegate
        public bool PosTest4()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest4: Use the same type's different static method to create two delegate which delegate object is the same,their hashcode is equal ");

            try
            {
                DelegateGetHashCode delctor       = new DelegateGetHashCode();
                booldelegate        workDelegate1 = new booldelegate(TestClass.Working_Bool);
                booldelegate        workDelegate  = new booldelegate(TestClass.Completed_Bool);
                if (workDelegate.GetHashCode() != workDelegate1.GetHashCode())
                {
                    TestLibrary.TestFramework.LogError("007", "HashCode is not excepted ");
                    retVal = false;
                }

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

            return(retVal);
        }
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        // one delegate object  is booldelegate
        // the other is voiddelegate
        public bool PosTest1()
        {
            bool retVal = true;
            TestLibrary.TestFramework.BeginScenario("PosTest1: hash code of two different 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 );
                voiddelegate workDelegate1 = new voiddelegate(new TestClass(1).StartWork_Void);
                if (workDelegate.GetHashCode() == workDelegate1.GetHashCode())
                {
                    TestLibrary.TestFramework.LogError("001", "HashCode is not excepted ");
                    retVal = false;
                }
               
                workDelegate();
                workDelegate1();

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

            return retVal;
        }
Exemple #4
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 voiddelegate
        public bool PosTest1()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest1: hash code of two different 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);
                voiddelegate        workDelegate1 = new voiddelegate(new TestClass(1).StartWork_Void);
                if (workDelegate.GetHashCode() == workDelegate1.GetHashCode())
                {
                    TestLibrary.TestFramework.LogError("001", "HashCode is not excepted ");
                    retVal = false;
                }

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

            return(retVal);
        }
Exemple #5
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);
        }
Exemple #6
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        // the same delegate object  is booldelegate
        public bool PosTest7()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest7:  Use the different instance's same instance method to create two delegate which delegate object is the same, their hashcode is different");

            try
            {
                DelegateGetHashCode delctor       = new DelegateGetHashCode();
                booldelegate        workDelegate  = new booldelegate(new TestClass(1).StartWork_Bool);
                booldelegate        workDelegate1 = new booldelegate(new TestClass1(2).StartWork_Bool);

                if (workDelegate.GetHashCode() == workDelegate1.GetHashCode())
                {
                    TestLibrary.TestFramework.LogError("013", "HashCode is not excepted ");
                    retVal = false;
                }

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

            return(retVal);
        }
Exemple #7
0
        public static int Main()
        {
            DelegateGetHashCode DelegateGetHashCode = new DelegateGetHashCode();

            TestLibrary.TestFramework.BeginTestCase("DelegateGetHashCode");

            if (DelegateGetHashCode.RunTests())
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("PASS");
                return 100;
            }
            else
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("FAIL");
                return 0;
            }
        }
        public static int Main()
        {
            DelegateGetHashCode DelegateGetHashCode = new DelegateGetHashCode();

            TestLibrary.TestFramework.BeginTestCase("DelegateGetHashCode");

            if (DelegateGetHashCode.RunTests())
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("PASS");
                return 100;
            }
            else
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("FAIL");
                return 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 booldelegate1
        public bool PosTest2()
        {
            bool retVal = true;
            //Type,target, method, and invocation list 
            TestLibrary.TestFramework.BeginScenario("PosTest2: hash code of two different delegate object even though  they invoke the same function  is not equal ");

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

                workDelegate();
                workDelegate1();

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

            return retVal;
        }
        // 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;
        }
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        // the same delegate object  is booldelegate
        public bool PosTest7()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest7:  Use the different instance's same instance method to create two delegate which delegate object is the same,their hashcode is equal");

            try
            {
                DelegateGetHashCode delctor = new DelegateGetHashCode();
                booldelegate workDelegate = new booldelegate(new TestClass(1).StartWork_Bool);
                booldelegate workDelegate1 = new booldelegate(new TestClass1(2).StartWork_Bool );

                if (workDelegate.GetHashCode()!=workDelegate1.GetHashCode())
                {
                    TestLibrary.TestFramework.LogError("013", "HashCode is not excepted ");
                    retVal = false;
                }

                workDelegate();
                workDelegate1();

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

            return retVal;
        }
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        // the same delegate object  is booldelegate
        public bool PosTest6()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest6:  Use the different type's same static method to create two delegate ,which delegate object is the same,their hashcode is equal");

            try
            {
                DelegateGetHashCode delctor = new DelegateGetHashCode();
                booldelegate workDelegate = new booldelegate(TestClass.Completed_Bool);
                booldelegate workDelegate1 = new booldelegate(TestClass1.Completed_Bool);
              
                if (workDelegate.GetHashCode()!=workDelegate1.GetHashCode())
                {
                    TestLibrary.TestFramework.LogError("011", "HashCode is not excepted");
                    retVal = false;
                }

                workDelegate();
                workDelegate1();

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

            return retVal;
        }