public void PosTest5() { TestClass1 tc1 = new TestClass1(); Type tpA = tc1.GetType(); EventInfo eventinfo = tpA.GetEvent("Event4", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo methodinfo = eventinfo.GetRemoveMethod(); Assert.Null(methodinfo); }
public void PosTest3() { TestClass1 tc1 = new TestClass1(); Type tpA = tc1.GetType(); EventInfo eventinfo = tpA.GetEvent("Event3", BindingFlags.NonPublic | BindingFlags.Instance); MethodInfo methodinfo = eventinfo.GetAddMethod(false); Assert.Null(methodinfo); }
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 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 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 PosTest2() { TestClass1 tc1 = new TestClass1(); Type tpA = tc1.GetType(); EventInfo eventinfo = tpA.GetEvent("Event1"); MethodInfo methodinfo = eventinfo.GetRemoveMethod(false); Assert.Equal("Void remove_Event1(Delegate1)", methodinfo.ToString()); }
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.RemoveEventHandler(tc2, new TestForEvent1(tc1.method1))); Assert.Contains("TargetException", e.GetType().FullName); }
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 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 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(); tc1.Event2 += new Delegate2(tc1.method2); Type tpA = tc1.GetType(); EventInfo eventinfo = tpA.GetEvent("Event2", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo methodinfo = eventinfo.GetAddMethod(); Assert.Null(methodinfo); }
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 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)); }); }
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 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 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)); }); }
public void NegTest1() { try { TestClass1 tc1 = new TestClass1(); Type tpA = tc1.GetType(); EventInfo eventinfo = tpA.GetEvent("Event1"); eventinfo.AddEventHandler(null, new TestForEvent1(tc1.method2)); Assert.True(false); } catch (Exception e) { if (e.GetType().ToString() != "System.Reflection.TargetException") { Assert.True(false); } } }
public void NegTest2() { try { TestClass1 tc1 = new TestClass1(); Type tpA = tc1.GetType(); EventInfo eventinfo = tpA.GetEvent("Event1"); TestClass2 tc2 = new TestClass2(); eventinfo.AddEventHandler(tc2, new TestForEvent1(tc1.method2)); Assert.True(false); } catch (Exception e) { if (!e.GetType().FullName.Equals("System.Reflection.TargetException")) { Assert.True(false); } } }
public void NegTest3() { try { TestClass1 tc1 = new TestClass1(); Type tpA = tc1.GetType(); EventInfo eventinfo = tpA.GetEvent("Event1"); eventinfo.RemoveEventHandler(null, new TestForEvent1(tc1.method1)); Assert.False(true); } catch (Exception e) { // TargetException is not defined in the OOB or Win8P, but using string comparison still seems to work if (!e.GetType().FullName.Contains("TargetException")) { Assert.False(true); } } }
public void NegTest2() { try { TestClass1 tc1 = new TestClass1(); Type tpA = tc1.GetType(); EventInfo eventinfo = tpA.GetEvent("Event1"); TestClass2 tc2 = new TestClass2(); eventinfo.RemoveEventHandler(tc2, new TestForEvent1(tc1.method1)); Assert.False(true); } catch (Exception e) { // TargetException is not defined in the OOB or Win8P, but using string comparison still seems to work if (!e.GetType().FullName.Contains("TargetException")) { Assert.False(true); } } }