コード例 #1
0
        public static int Main()
        {
            DelegateCombineImpl delegateCombineImpl = new DelegateCombineImpl();

            TestLibrary.TestFramework.BeginTestCase("DelegateCombineImpl");



            if (delegateCombineImpl.RunTests())
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("PASS");
                return(100);
            }
            else
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("FAIL");
                return(0);
            }
        }
コード例 #2
0
        public static int Main()
        {
            DelegateCombineImpl delegateCombineImpl = new DelegateCombineImpl();

            TestLibrary.TestFramework.BeginTestCase("DelegateCombineImpl");



            if (delegateCombineImpl.RunTests())
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("PASS");
                return 100;

            }
            else
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("FAIL");
                return 0;
            }
        }
コード例 #3
0
        private bool CombineImpl(booldelegate delegatesrc, identify_null start)
        {
            DelegateCombineImpl delctor      = new DelegateCombineImpl();
            TestClass           testinstance = new TestClass();

            string       sFlag       = string.Empty;
            string       sFlagAdd    = string.Empty;
            booldelegate combineImpl = delegatesrc;

            if (start == identify_null.c_Start_null_false)
            {
                delctor.starkWork = new booldelegate(testinstance.StartWork_Bool);
                combineImpl      += (booldelegate)delctor.starkWork;
                sFlagAdd          = c_StartWork;
            }
            else if (start == identify_null.c_Start_null_false_duplicate)
            {
                delctor.starkWork = new booldelegate(testinstance.StartWork_Bool);
                combineImpl      += (booldelegate)delctor.starkWork;
                sFlagAdd          = c_StartWork;
                //The invocation list can contain duplicate entries; that is, entries that refer to the same method on the same object.
                combineImpl += (booldelegate)delctor.starkWork;
                sFlagAdd    += sFlagAdd;
            }
            else if (start == identify_null.c_Start_null_true)
            {
                delctor.starkWork = null;
                combineImpl      += (booldelegate)delctor.starkWork;
            }
            else if (start == identify_null.c_Working_null_false)
            {
                delctor.working = new booldelegate(testinstance.Working_Bool);
                combineImpl    += (booldelegate)delctor.working;
                sFlagAdd        = c_Working;
            }
            else
            {
                delctor.working = null;
                combineImpl    += (booldelegate)delctor.working;
            }

            if (combineImpl == null)
            {
                return(true);
            }

            for (IEnumerator itr = combineImpl.GetInvocationList().GetEnumerator(); itr.MoveNext();)
            {
                booldelegate bd = (booldelegate)itr.Current;
                //the filter is to get the delegate which is appended through equals method.
                if (bd.Equals(delctor.starkWork))
                {
                    sFlag += c_StartWork;
                }
                if (bd.Equals(delctor.working))
                {
                    sFlag += c_Working;
                }
            }
            combineImpl();
            //judge delegate is appended  to the end of the invocation list of the current
            if (sFlag == sFlagAdd)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        private bool CombineImpl(booldelegate delegatesrc,identify_null start)
        {
            DelegateCombineImpl delctor = new DelegateCombineImpl();
            TestClass testinstance = new TestClass();
            
            string sFlag = string.Empty;
            string sFlagAdd=string.Empty ;
            booldelegate combineImpl = delegatesrc;
            if (start == identify_null.c_Start_null_false)
            {
                delctor.starkWork = new booldelegate(testinstance.StartWork_Bool);
                combineImpl += (booldelegate)delctor.starkWork;
                sFlagAdd = c_StartWrok;
               
            }
            else if (start == identify_null.c_Start_null_false_duplicate )
            {
                delctor.starkWork = new booldelegate(testinstance.StartWork_Bool);
                combineImpl += (booldelegate)delctor.starkWork;
                sFlagAdd = c_StartWrok;
                //The invocation list can contain duplicate entries; that is, entries that refer to the same method on the same object.
                combineImpl += (booldelegate)delctor.starkWork;
                sFlagAdd += sFlagAdd;
            }
            else if(start==identify_null.c_Start_null_true )
            {
                delctor.starkWork = null;
                combineImpl += (booldelegate)delctor.starkWork;
            }
            else if (start == identify_null.c_Working_null_false)
            {
                delctor.working  = new booldelegate(testinstance.Working_Bool );
                combineImpl += (booldelegate)delctor.working;
                 sFlagAdd=c_Working  ;
            }
            else
            {
                delctor.working = null;
                combineImpl += (booldelegate)delctor.working;
            }
          
            if (combineImpl == null)
            {
                return true;
            }

            for (IEnumerator itr = combineImpl.GetInvocationList().GetEnumerator(); itr.MoveNext(); )
            {
                booldelegate bd = (booldelegate)itr.Current;
                //the filter is to get the delegate which is appended through equals method. 
                if (bd.Equals(delctor.starkWork))
                {
                    sFlag += c_StartWrok;
                }
                if (bd.Equals(delctor.working))
                {
                    sFlag += c_Working;
                }
            }
            combineImpl();
            //judge delegate is appended  to the end of the invocation list of the current 
            if (sFlag == sFlagAdd)
                return true;
            else
                return false;
            
        }