コード例 #1
0
    public bool PosTest16()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest16: Initialize a delegate with an anonymous function");

        try
        {
            DelegateDefinitions dd = new DelegateDefinitions();
            dd.ReferenceValueParameterReferenceDelegate = delegate(object val1, int val2)
            {
                if (!val1.Equals(DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER))
                {
                    VerificationAgent.ThrowVerificationException(
                        "First input reference parameter is not expected",
                        val1,
                        DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER);
                }

                if (DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER != val2)
                {
                    VerificationAgent.ThrowVerificationException(
                        "Second input value parameter is not expected",
                        val2,
                        DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER);
                }

                return(DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER);
            };

            if (null == dd.ReferenceValueParameterReferenceDelegate)
            {
                TestLibrary.TestFramework.LogError("039", "Failed to assign a call back function to a delegate");
                retVal = false;
            }

            object returnObject = dd.ReferenceValueParameterReferenceDelegate(
                DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER,
                DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER);

            if (!returnObject.Equals(DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER))
            {
                TestLibrary.TestFramework.LogError("040", "Incorrect delegate return value: " + returnObject);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("041", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
コード例 #2
0
    public bool NegTest5()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("NegTest5: Return type is a reference type with 1 reference type parameter and 1 value  type parameter");

        try
        {
            DelegateDefinitions dd = new DelegateDefinitions();
            dd.ReferenceValueParameterReferenceDelegate =
                new ReferenceValueParameterReferenceDelegate(dd.TestReferenceValueParameterReferenceCallbackWithNullValue);

            dd.ReferenceValueParameterReferenceDelegate(null, DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER);
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("052", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
コード例 #3
0
    public bool PosTest17()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest17: Initialize a delegate with an private instance method");

        try
        {
            DelegateDefinitions dd = new DelegateDefinitions();
            dd.ReferenceValueParameterReferenceDelegate =
                new ReferenceValueParameterReferenceDelegate(TestReferenceValueParameterReferencePrivateCallback);

            if (null == dd.ReferenceValueParameterReferenceDelegate)
            {
                TestLibrary.TestFramework.LogError("042", "Failed to assign a private call back function to a delegate");
                retVal = false;
            }

            object returnObject = dd.ReferenceValueParameterReferenceDelegate(
                DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER,
                DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER);

            if (!returnObject.Equals(DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER))
            {
                TestLibrary.TestFramework.LogError("043", "Incorrect delegate return value: " + returnObject);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("044", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
コード例 #4
0
    public bool PosTest15()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest15: Return value is a reference type, with 1 reference type parameter and 1 value type parameter, then set a static function");

        try
        {
            DelegateDefinitions dd = new DelegateDefinitions();
            dd.ReferenceValueParameterReferenceDelegate =
                new ReferenceValueParameterReferenceDelegate(DelegateDefinitions.TestReferenceValueParameterReferenceStaticCallback);
            if (null == dd.ReferenceValueParameterReferenceDelegate)
            {
                TestLibrary.TestFramework.LogError("036", "Failed to assign a call back function to a delegate");
                retVal = false;
            }

            object returnObject = dd.ReferenceValueParameterReferenceDelegate(
                DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER,
                DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER);

            if (!returnObject.Equals(DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER))
            {
                TestLibrary.TestFramework.LogError("037", "Incorrect delegate return value: " + returnObject);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("038", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
コード例 #5
0
    public bool NegTest5()
    {
        bool retVal = true;
        
        TestLibrary.TestFramework.BeginScenario("NegTest5: Return type is a reference type with 1 reference type parameter and 1 value  type parameter");

        try
        {
            DelegateDefinitions dd = new DelegateDefinitions();
            dd.ReferenceValueParameterReferenceDelegate =
                new ReferenceValueParameterReferenceDelegate(dd.TestReferenceValueParameterReferenceCallbackWithNullValue);

            dd.ReferenceValueParameterReferenceDelegate(null, DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER);
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("052", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
コード例 #6
0
    public bool PosTest17()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest17: Initialize a delegate with an private instance method");

        try
        {
            DelegateDefinitions dd = new DelegateDefinitions();
            dd.ReferenceValueParameterReferenceDelegate =
                new ReferenceValueParameterReferenceDelegate(TestReferenceValueParameterReferencePrivateCallback);

            if (null == dd.ReferenceValueParameterReferenceDelegate)
            {
                TestLibrary.TestFramework.LogError("042", "Failed to assign a private call back function to a delegate");
                retVal = false;
            }

            object returnObject = dd.ReferenceValueParameterReferenceDelegate(
                DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER,
                DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER);

            if (!returnObject.Equals(DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER))
            {
                TestLibrary.TestFramework.LogError("043", "Incorrect delegate return value: " + returnObject);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("044", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
コード例 #7
0
    public bool PosTest16()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest16: Initialize a delegate with an anonymous function");

        try
        {
            DelegateDefinitions dd = new DelegateDefinitions();
            dd.ReferenceValueParameterReferenceDelegate = delegate(object val1, int val2)
            {
                if (!val1.Equals(DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER))
                    VerificationAgent.ThrowVerificationException(
                        "First input reference parameter is not expected",
                        val1,
                        DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER);

                if (DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER != val2)
                    VerificationAgent.ThrowVerificationException(
                        "Second input value parameter is not expected",
                        val2,
                        DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER);

                return DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER;
            };

            if (null == dd.ReferenceValueParameterReferenceDelegate)
            {
                TestLibrary.TestFramework.LogError("039", "Failed to assign a call back function to a delegate");
                retVal = false;
            }

            object returnObject = dd.ReferenceValueParameterReferenceDelegate(
                DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER,
                DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER);

            if (!returnObject.Equals(DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER))
            {
                TestLibrary.TestFramework.LogError("040", "Incorrect delegate return value: " + returnObject);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("041", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
コード例 #8
0
    public bool PosTest15()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest15: Return value is a reference type, with 1 reference type parameter and 1 value type parameter, then set a static function");

        try
        {
            DelegateDefinitions dd = new DelegateDefinitions();
            dd.ReferenceValueParameterReferenceDelegate =
                new ReferenceValueParameterReferenceDelegate(DelegateDefinitions.TestReferenceValueParameterReferenceStaticCallback);
            if (null == dd.ReferenceValueParameterReferenceDelegate)
            {
                TestLibrary.TestFramework.LogError("036", "Failed to assign a call back function to a delegate");
                retVal = false;
            }

            object returnObject = dd.ReferenceValueParameterReferenceDelegate(
                DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER,
                DelegateDefinitions.c_DELEGATE_TEST_DEFAULT_VALUE_PARAMETER);

            if (!returnObject.Equals(DelegateDefinitions.c_DELEGATE_TEST_DEFAUTL_REFERENCE_PARAMETER))
            {
                TestLibrary.TestFramework.LogError("037", "Incorrect delegate return value: " + returnObject);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("038", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }