public void NegTest1()
        {
            DynamicMethod            testDynMethod;
            TestCreateDelegateOwner2 target = new TestCreateDelegateOwner2();

            testDynMethod = this.CreateDynMethod(_DYNAMIC_METHOD_OWNER_TYPE);
            Assert.Throws <InvalidOperationException>(() =>
            {
                UseLikeStatic2 staticCallBack = (UseLikeStatic2)testDynMethod.CreateDelegate(typeof(UseLikeStatic2));
            });
        }
        public void NegTest4()
        {
            DynamicMethod            testDynMethod;
            FieldInfo                fieldInfo;
            TestCreateDelegateOwner2 target = new TestCreateDelegateOwner2();

            fieldInfo = _DYNAMIC_METHOD_OWNER_TYPE.GetField(
                c_FIELD_NAME,
                BindingFlags.NonPublic |
                BindingFlags.Instance);

            testDynMethod = this.CreateDynMethod(_DYNAMIC_METHOD_OWNER_TYPE);
            this.EmitDynMethodBody(testDynMethod, fieldInfo);
            Assert.Throws <ArgumentException>(() =>
            {
                InvalidParamType2 invalidCallBack = (InvalidParamType2)testDynMethod.CreateDelegate(typeof(InvalidParamType2));
            });
        }
        public void PosTest3()
        {
            DynamicMethod testDynMethod;
            FieldInfo fieldInfo;
            TestCreateDelegateOwner2 target = new TestCreateDelegateOwner2();
            int newId = 100;

            bool actualResult;
            fieldInfo = _DYNAMIC_METHOD_OWNER_TYPE.GetField(
                                c_FIELD_NAME,
                                BindingFlags.NonPublic |
                                BindingFlags.Instance);

            testDynMethod = this.CreateDynMethod(this.CurrentModule);
            this.EmitDynMethodBody(testDynMethod, fieldInfo);

            UseLikeStatic2 staticCallBack = (UseLikeStatic2)testDynMethod.CreateDelegate(typeof(UseLikeStatic2));
            actualResult = target.ID == staticCallBack(target, newId);
            actualResult = (target.ID == newId) && actualResult;

            Assert.True(actualResult, "Failed to create delegate for dynamic method.");
        }
        public void PosTest1()
        {
            DynamicMethod            testDynMethod;
            FieldInfo                fieldInfo;
            TestCreateDelegateOwner2 target = new TestCreateDelegateOwner2();
            int newId = 100;

            bool actualResult;

            fieldInfo = _DYNAMIC_METHOD_OWNER_TYPE.GetField(
                c_FIELD_NAME,
                BindingFlags.NonPublic |
                BindingFlags.Instance);

            testDynMethod = this.CreateDynMethod(_DYNAMIC_METHOD_OWNER_TYPE);
            this.EmitDynMethodBody(testDynMethod, fieldInfo);

            UseLikeStatic2 staticCallBack = (UseLikeStatic2)testDynMethod.CreateDelegate(typeof(UseLikeStatic2));

            actualResult = target.ID == staticCallBack(target, newId);
            actualResult = (target.ID == newId) && actualResult;
            Assert.True(actualResult, "Failed to create delegate for dynamic method.");
        }
        public void NegTest4()
        {
            DynamicMethod testDynMethod;
            FieldInfo fieldInfo;
            TestCreateDelegateOwner2 target = new TestCreateDelegateOwner2();

            fieldInfo = _DYNAMIC_METHOD_OWNER_TYPE.GetField(
                                c_FIELD_NAME,
                                BindingFlags.NonPublic |
                                BindingFlags.Instance);

            testDynMethod = this.CreateDynMethod(_DYNAMIC_METHOD_OWNER_TYPE);
            this.EmitDynMethodBody(testDynMethod, fieldInfo);
            Assert.Throws<ArgumentException>(() =>
            {
                InvalidParamType2 invalidCallBack = (InvalidParamType2)testDynMethod.CreateDelegate(typeof(InvalidParamType2));
            });
        }
        public void NegTest1()
        {
            DynamicMethod testDynMethod;
            TestCreateDelegateOwner2 target = new TestCreateDelegateOwner2();

            testDynMethod = this.CreateDynMethod(_DYNAMIC_METHOD_OWNER_TYPE);
            Assert.Throws<InvalidOperationException>(() =>
            {
                UseLikeStatic2 staticCallBack = (UseLikeStatic2)testDynMethod.CreateDelegate(typeof(UseLikeStatic2));
            });
        }