Beispiel #1
0
        public static int Main()
        {
            DelegateCombine1 delegateCombine1 = new DelegateCombine1();

            TestLibrary.TestFramework.BeginTestCase("DelegateCombine1");



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

            }
            else
            {
                TestLibrary.TestFramework.EndTestCase();
                TestLibrary.TestFramework.LogInformation("FAIL");
                return 0;
            }
        }
Beispiel #2
0
        private string GetInvocationListFlag(identify_null start,identify_null working)
        {
            DelegateCombine1 delctor = new DelegateCombine1();
            TestClass testinstance = new TestClass();
            
            string sFlag = string.Empty;
            if (start == identify_null.c_Start_null_false)
            {
                delctor.starkWork = new booldelegate(testinstance.StartWork_Bool);
            }
            else
            {
                delctor.starkWork = null;
            }
            if (working == identify_null.c_Working_null_false)
            {
                delctor.working  = new booldelegate(testinstance.Working_Bool );
            }
            else
            {
                delctor.working = null;
            }
            booldelegate combine = (booldelegate)Delegate.Combine(delctor.starkWork, delctor.working);
            if (combine == null)
            {
                return string.Empty;
            }

            for (IEnumerator itr = combine.GetInvocationList().GetEnumerator(); itr.MoveNext(); )
            {
                booldelegate bd = (booldelegate)itr.Current;
                if (bd.Equals(delctor.starkWork))
                {
                    sFlag += c_StartWrok;
                }
                if (bd.Equals(delctor.working))
                {
                    sFlag += c_Working;
                }
            }
            combine();
            return sFlag;
        }
Beispiel #3
0
        // Returns true if the expected result is right
        // Returns false if the expected result is wrong
        public bool NegTest1()
        {
            bool retVal = true;

            TestLibrary.TestFramework.BeginScenario("NegTest1:Both a and b are not a null reference , and a and b are not instances of the same delegate type.");

            try
            {
                DelegateCombine1 delctor = new DelegateCombine1();
                TestClass testinstance = new TestClass();
                delctor.starkWork = new booldelegate(testinstance.StartWork_Bool);
                delctor.completeWork = new voiddelegate(testinstance.CompleteWork_Void);

                object obj = Delegate.Combine(delctor.starkWork, delctor.completeWork);

                TestLibrary.TestFramework.LogError("009", "a ArgumentException should be throw ");
                retVal = false;
      
            }
            catch (ArgumentException)
            {
            
            }

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

            return retVal;
        }