Ejemplo n.º 1
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest7()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest7:  Use the different instance's same instance method to create two delegate ,then use equals method to compare");

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

                if (workDelegate.Equals(workDelegate1))
                {
                    TestLibrary.TestFramework.LogError("016", "Equals method return error ");
                    retVal = false;
                }

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

            return(retVal);
        }
Ejemplo n.º 2
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest4()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest4: Use the same type's different static method to create two delegate ,then use equals method to compare");

            try
            {
                DelegateEquals delctor = new DelegateEquals();
                delctor.starkWork = new booldelegate(TestClass.Working_Bool);
                booldelegate workDelegate = new booldelegate(TestClass.Completed_Bool);
                if (workDelegate.Equals((booldelegate)delctor.starkWork))
                {
                    TestLibrary.TestFramework.LogError("010", "Equals method return error ");
                    retVal = false;
                }

                workDelegate();
                ((booldelegate)delctor.starkWork)();
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("011", "Unexpected exception: " + e);
                retVal = false;
            }

            return(retVal);
        }
Ejemplo n.º 3
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest6()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest6:  Use the different type's same static method to create two delegate ,then use equals method to compare");

            try
            {
                DelegateEquals delctor       = new DelegateEquals();
                booldelegate   workDelegate  = new booldelegate(TestClass.Completed_Bool);
                booldelegate   workDelegate1 = new booldelegate(TestClass1.Completed_Bool);

                if (workDelegate.Equals(workDelegate1))
                {
                    TestLibrary.TestFramework.LogError("014", "Equals method return error ");
                    retVal = false;
                }

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

            return(retVal);
        }
Ejemplo n.º 4
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest3()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest3: Use the same type's same static method to create two delegate ,then use equals method to compare");

            try
            {
                DelegateEquals delctor = new DelegateEquals();
                delctor.starkWork = new booldelegate(TestClass.Working_Bool);
                booldelegate workDelegate = new booldelegate(TestClass.Working_Bool);
                if (GetCompareResult(workDelegate, (booldelegate)delctor.starkWork))
                {
                    if (!workDelegate.Equals((booldelegate)delctor.starkWork))
                    {
                        TestLibrary.TestFramework.LogError("007", "Equals method return error ");
                        retVal = false;
                    }
                }
                else
                {
                    TestLibrary.TestFramework.LogError("008", "compare condition is error  ");
                    retVal = false;
                }
                workDelegate();
                ((booldelegate)delctor.starkWork)();
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("009", "Unexpected exception: " + e);
                retVal = false;
            }

            return(retVal);
        }
Ejemplo n.º 5
0
        public static int Main()
        {
            DelegateEquals DelegateEquals = new DelegateEquals();

            TestLibrary.TestFramework.BeginTestCase("DelegateEquals");

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

            TestLibrary.TestFramework.BeginTestCase("DelegateEquals");

            if (DelegateEquals.RunTests())
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("PASS");
                return 100;
            }
            else
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("FAIL");
                return 0;
            }
        }
Ejemplo n.º 7
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest2()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest2: Use the same instance's same instance method to create two different delegate ,then use equals method to compare");

            try
            {
                DelegateEquals delctor    = new DelegateEquals();
                TestClass      tcInstance = new TestClass(2);
                delctor.starkWork = new booldelegate(tcInstance.StartWork_Bool);
                booldelegate workDelegate = new booldelegate(tcInstance.StartWork_Bool);

                if (GetCompareResult(workDelegate, (booldelegate)delctor.starkWork))
                {
                    if (!workDelegate.Equals((booldelegate)delctor.starkWork))
                    {
                        TestLibrary.TestFramework.LogError("004", "Equals method return error ");
                        retVal = false;
                    }
                }
                else
                {
                    TestLibrary.TestFramework.LogError("005", "compare condition is error  ");
                    retVal = false;
                }
                workDelegate();
                ((booldelegate)delctor.starkWork)();
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
                retVal = false;
            }

            return(retVal);
        }
Ejemplo n.º 8
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest1()
        {
            bool retVal = true;

            //Type,target, method, and invocation list
            TestLibrary.TestFramework.BeginScenario("PosTest1: Use one delegate object to instance the other delegate object,then use equals method to compare");

            try
            {
                DelegateEquals delctor = new DelegateEquals();
                delctor.starkWork = new booldelegate(new TestClass(1).StartWork_Bool);
                booldelegate workDelegate = (booldelegate)delctor.starkWork;
                if (GetCompareResult(workDelegate, (booldelegate)delctor.starkWork))
                {
                    if (!workDelegate.Equals((booldelegate)delctor.starkWork))
                    {
                        TestLibrary.TestFramework.LogError("001", "Equals method return error ");
                        retVal = false;
                    }
                }
                else
                {
                    TestLibrary.TestFramework.LogError("002", "compare condition is error  ");
                    retVal = false;
                }
                workDelegate();
                ((booldelegate)delctor.starkWork)();
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e);
                retVal = false;
            }

            return(retVal);
        }
Ejemplo n.º 9
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest1()
        {
            bool retVal = true;
            //Type,target, method, and invocation list 
            TestLibrary.TestFramework.BeginScenario("PosTest1: Use one delegate object to instance the other delegate object,then use equals method to compare");

            try
            {
                DelegateEquals delctor = new DelegateEquals();
                delctor.starkWork = new booldelegate(new TestClass(1).StartWork_Bool);
                booldelegate workDelegate = (booldelegate)delctor.starkWork;
                if(GetCompareResult(workDelegate ,(booldelegate)delctor.starkWork))
                {
                    if (!workDelegate.Equals((booldelegate)delctor.starkWork))
                    {
                        TestLibrary.TestFramework.LogError("001", "Equals method return error ");
                        retVal = false;
                    }
                }
                else
                {
                    TestLibrary.TestFramework.LogError("002", "compare condition is error  ");
                    retVal = false;
                }
                workDelegate();
                ((booldelegate)delctor.starkWork)();

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

            return retVal;
        }
Ejemplo n.º 10
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest2()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest2: Use the same instance's same instance method to create two different delegate ,then use equals method to compare");

            try
            {
                DelegateEquals delctor = new DelegateEquals();
                TestClass tcInstance = new TestClass(2);
                delctor.starkWork = new booldelegate(tcInstance.StartWork_Bool);
                booldelegate workDelegate = new booldelegate(tcInstance.StartWork_Bool);
                
                if (GetCompareResult(workDelegate, (booldelegate)delctor.starkWork))
                {
                    if (!workDelegate.Equals((booldelegate)delctor.starkWork))
                    {
                        TestLibrary.TestFramework.LogError("004", "Equals method return error ");
                        retVal = false;
                    }
                }
                else
                {
                    TestLibrary.TestFramework.LogError("005", "compare condition is error  ");
                    retVal = false;
                }
                workDelegate();
                ((booldelegate)delctor.starkWork)();
                
            }
            catch (Exception e)
            {
                TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
                retVal = false;
            }

            return retVal;
        }
Ejemplo n.º 11
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest7()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest7:  Use the different instance's same instance method to create two delegate ,then use equals method to compare");

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

                if (workDelegate.Equals(workDelegate1))
                {
                    TestLibrary.TestFramework.LogError("016", "Equals method return error ");
                    retVal = false;
                }

                workDelegate();
                workDelegate1();

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

            return retVal;
        }
Ejemplo n.º 12
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest6()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest6:  Use the different type's same static method to create two delegate ,then use equals method to compare");

            try
            {
                DelegateEquals delctor = new DelegateEquals();
                booldelegate workDelegate = new booldelegate(TestClass.Completed_Bool);
                booldelegate workDelegate1 = new booldelegate(TestClass1.Completed_Bool);
              
                if (workDelegate.Equals(workDelegate1))
                {
                    TestLibrary.TestFramework.LogError("014", "Equals method return error ");
                    retVal = false;
                }

                workDelegate();
                workDelegate1();

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

            return retVal;
        }
Ejemplo n.º 13
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest4()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest4: Use the same type's different static method to create two delegate ,then use equals method to compare");

            try
            {
                DelegateEquals delctor = new DelegateEquals();
                delctor.starkWork = new booldelegate(TestClass.Working_Bool);
                booldelegate workDelegate = new booldelegate(TestClass.Completed_Bool);
                if (workDelegate.Equals((booldelegate)delctor.starkWork))
                {
                    TestLibrary.TestFramework.LogError("010", "Equals method return error ");
                    retVal = false;
                }
               
                workDelegate();
                ((booldelegate)delctor.starkWork)();

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

            return retVal;
        }
Ejemplo n.º 14
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool PosTest3()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("PosTest3: Use the same type's same static method to create two delegate ,then use equals method to compare");

            try
            {
                DelegateEquals delctor = new DelegateEquals();
                delctor.starkWork = new booldelegate(TestClass.Working_Bool);
                booldelegate workDelegate = new booldelegate(TestClass.Working_Bool);
                if (GetCompareResult(workDelegate, (booldelegate)delctor.starkWork))
                {
                    if (!workDelegate.Equals((booldelegate)delctor.starkWork))
                    {
                        TestLibrary.TestFramework.LogError("007", "Equals method return error ");
                        retVal = false;
                    }
                }
                else
                {
                    TestLibrary.TestFramework.LogError("008", "compare condition is error  ");
                    retVal = false;
                }
                workDelegate();
                ((booldelegate)delctor.starkWork)();

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

            return retVal;
        }