public void PosTest1()
 {
     TestClass1 tc1 = new TestClass1();
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event1");
     MethodInfo methodinfo = eventinfo.GetRemoveMethod();
     Assert.Equal("Void remove_Event1(Delegate1)", methodinfo.ToString());
 }
 public void PosTest6()
 {
     TestClass1 tc1 = new TestClass1();
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event4", BindingFlags.Instance | BindingFlags.NonPublic);
     MethodInfo methodinfo = eventinfo.GetAddMethod(true);
     Assert.Equal("Void add_Event4(Delegate2)", methodinfo.ToString());
 }
 public void PosTest4()
 {
     TestClass1 tc1 = new TestClass1();
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event4", BindingFlags.Instance | BindingFlags.NonPublic);
     MethodInfo methodinfo = eventinfo.GetAddMethod();
     Assert.Null(methodinfo);
 }
 public void NegTest3()
 {
     TestClass1 tc1 = new TestClass1();
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event1");
     Exception e = Assert.ThrowsAny<Exception>(() => eventinfo.RemoveEventHandler(null, new TestForEvent1(tc1.method1)));
     Assert.Contains("TargetException", e.GetType().FullName);
 }
 public void PosTest5()
 {
     TestClass1 tc1 = new TestClass1();
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event3", BindingFlags.NonPublic | BindingFlags.Instance);
     MethodInfo methodinfo = eventinfo.GetRemoveMethod(true);
     Assert.Equal("Void remove_Event3(Delegate1)", methodinfo.ToString());
 }
 public void PosTest5()
 {
     TestClass1 tc1 = new TestClass1();
     tc1.Event2 += new Delegate2(tc1.method2);
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event2", BindingFlags.Instance | BindingFlags.NonPublic);
     MethodInfo methodinfo = eventinfo.GetAddMethod(false);
     Assert.Null(methodinfo);
 }
示例#7
0
        public void PosTest6()
        {
            TestClass1 tc1        = new TestClass1();
            Type       tpA        = tc1.GetType();
            EventInfo  eventinfo  = tpA.GetEvent("Event4", BindingFlags.Instance | BindingFlags.NonPublic);
            MethodInfo methodinfo = eventinfo.GetAddMethod(true);

            Assert.Equal("Void add_Event4(Delegate2)", methodinfo.ToString());
        }
示例#8
0
        public void PosTest4()
        {
            TestClass1 tc1        = new TestClass1();
            Type       tpA        = tc1.GetType();
            EventInfo  eventinfo  = tpA.GetEvent("Event4", BindingFlags.Instance | BindingFlags.NonPublic);
            MethodInfo methodinfo = eventinfo.GetAddMethod();

            Assert.Null(methodinfo);
        }
        public void PosTest1()
        {
            TestClass1 tc1        = new TestClass1();
            Type       tpA        = tc1.GetType();
            EventInfo  eventinfo  = tpA.GetEvent("Event1");
            MethodInfo methodinfo = eventinfo.GetRemoveMethod();

            Assert.Equal("Void remove_Event1(Delegate1)", methodinfo.ToString());
        }
示例#10
0
 public void PosTest3()
 {
     TestClass1 tc1 = new TestClass1();
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event2");
     eventinfo.AddEventHandler(tc1, new TestForEvent1(tc1.method3));
     tc1.method();
     Assert.Equal(1, TestClass1.StaticVariable3);
 }
示例#11
0
 public void NegTest2()
 {
     TestClass1 tc1 = new TestClass1();
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event1");
     TestClass2 tc2 = new TestClass2();
     Exception e = Assert.ThrowsAny<Exception>(() => eventinfo.AddEventHandler(tc2, new TestForEvent1(tc1.method2)));
     Assert.Equal("System.Reflection.TargetException", e.GetType().FullName);
 }
        public void NegTest3()
        {
            TestClass1 tc1       = new TestClass1();
            Type       tpA       = tc1.GetType();
            EventInfo  eventinfo = tpA.GetEvent("Event1");
            Exception  e         = Assert.ThrowsAny <Exception>(() => eventinfo.RemoveEventHandler(null, new TestForEvent1(tc1.method1)));

            Assert.Contains("TargetException", e.GetType().FullName);
        }
示例#13
0
        public void PosTest5()
        {
            TestClass1 tc1        = new TestClass1();
            Type       tpA        = tc1.GetType();
            EventInfo  eventinfo  = tpA.GetEvent("Event3", BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo methodinfo = eventinfo.GetRemoveMethod(true);

            Assert.Equal("Void remove_Event3(Delegate1)", methodinfo.ToString());
        }
示例#14
0
 public void PosTest1()
 {
     TestClass1 tc1 = new TestClass1();
     tc1.Event1 += new Delegate1(tc1.method1);
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event1");
     MethodInfo methodinfo = eventinfo.GetAddMethod();
     Assert.Equal("Void add_Event1(Delegate1)", methodinfo.ToString());
 }
        public void PosTest3()
        {
            TestClass1 tc1       = new TestClass1();
            Type       tpA       = tc1.GetType();
            EventInfo  eventinfo = tpA.GetEvent("Event2");

            eventinfo.AddEventHandler(tc1, new TestForEvent1(tc1.method3));
            tc1.method();
            Assert.Equal(1, TestClass1.StaticVariable3);
        }
        public void NegTest2()
        {
            TestClass1 tc1       = new TestClass1();
            Type       tpA       = tc1.GetType();
            EventInfo  eventinfo = tpA.GetEvent("Event1");
            TestClass2 tc2       = new TestClass2();
            Exception  e         = Assert.ThrowsAny <Exception>(() => eventinfo.AddEventHandler(tc2, new TestForEvent1(tc1.method2)));

            Assert.Equal("System.Reflection.TargetException", e.GetType().FullName);
        }
 public void NegTest1()
 {
     TestClass1 tc1 = new TestClass1();
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event3", BindingFlags.NonPublic | BindingFlags.Instance);
     Assert.Throws<InvalidOperationException>(() =>
    {
        eventinfo.RemoveEventHandler(tc1, new TestForEvent1(tc1.method3));
    });
 }
示例#18
0
        public void PosTest1()
        {
            TestClass1 tc1 = new TestClass1();

            tc1.Event1 += new Delegate1(tc1.method1);
            Type       tpA        = tc1.GetType();
            EventInfo  eventinfo  = tpA.GetEvent("Event1");
            MethodInfo methodinfo = eventinfo.GetAddMethod();

            Assert.Equal("Void add_Event1(Delegate1)", methodinfo.ToString());
        }
        public void NegTest1()
        {
            TestClass1 tc1       = new TestClass1();
            Type       tpA       = tc1.GetType();
            EventInfo  eventinfo = tpA.GetEvent("Event3", BindingFlags.NonPublic | BindingFlags.Instance);

            Assert.Throws <InvalidOperationException>(() =>
            {
                eventinfo.RemoveEventHandler(tc1, new TestForEvent1(tc1.method3));
            });
        }
示例#20
0
        public void PosTest5()
        {
            TestClass1 tc1 = new TestClass1();

            tc1.Event2 += new Delegate2(tc1.method2);
            Type       tpA        = tc1.GetType();
            EventInfo  eventinfo  = tpA.GetEvent("Event2", BindingFlags.Instance | BindingFlags.NonPublic);
            MethodInfo methodinfo = eventinfo.GetAddMethod(false);

            Assert.Null(methodinfo);
        }
 public void PosTest2()
 {
     TestClass1 tc1 = new TestClass1();
     Type tpA = tc1.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event2");
     eventinfo.AddEventHandler(null, new TestForEvent1(tc1.method2));
     tc1.method02();
     eventinfo.RemoveEventHandler(null, new TestForEvent1(tc1.method2));
     tc1.method02();
     Assert.Equal(1, TestClass1.m_StaticVariable2);
 }
        public void PosTest2()
        {
            TestClass1 tc1       = new TestClass1();
            Type       tpA       = tc1.GetType();
            EventInfo  eventinfo = tpA.GetEvent("Event2");

            eventinfo.AddEventHandler(null, new TestForEvent1(tc1.method2));
            tc1.method02();
            eventinfo.RemoveEventHandler(null, new TestForEvent1(tc1.method2));
            tc1.method02();
            Assert.Equal(1, TestClass1.m_StaticVariable2);
        }